0
在這種情況下,靜態變量textView包含在Holder結構中。
但我遇到了一個問題,每次用戶調用此函數時都必須設置「Holder.textView.fieldEditor = true」。
我該如何讓這個動作只運行一次?如何在函數中設置靜態變量的屬性
func myTextView() -> NSTextView {
struct Holder {
static var textView = NSTextView()
}
Holder.textView.fieldEditor = true
return Holder.textView
}