0
我試圖創建的dictionary<String,NSImage>
一個陣列,
所以我這樣做:斯威夫特:數組[字符串:NSImage中]
class PreferencesController : NSObject{
var generalImage = NSImage(named: "NSAdvanced");
var textEditingImage = NSImage(named: "NSFontPanel");
var GUIImage = NSImage(named: "NSColorPanel");
var preferencesOptionTableList : NSMutableArray = [
["name":"General"],
["name":"Text Editing"],
["name":"GUI"]];
var preferencesOptionTableImageList : [[String:NSImage]] = [["image":textEditingImage]];
}
但我得到這個錯誤:
PreferencesController.Type does not have a member named
'textEditingImage'
請幫幫我我還是不知道在一小時的搜索後要做什麼
您好,感謝的答覆。我試過這個「var preferencesOptionTableImageList = [NSDictionary(object:textEditingImage?,forKey:」image「)]; 」但仍然是相同的錯誤 – 2015-02-09 04:22:54
看到我的新更新(未經測試)的例子。 – MirekE 2015-02-09 04:25:32
@戚昊燕,加個?在一個可選的結束時只解開鏈接事件。嘗試var textEditingImage = NSImage(名爲:「NSFontPanel」)! – TheCodingArt 2015-02-09 04:25:49