相关疑难解决方法(0)

来自swift中字典键的数组

尝试使用swift中字典中的键填充数组.

var componentArray: [String]

let dict = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("Components", ofType: "plist")!)
componentArray = dict.allKeys
Run Code Online (Sandbox Code Playgroud)

这将返回以下错误:'AnyObject'与string不同

也试过了

componentArray = dict.allKeys as String 
Run Code Online (Sandbox Code Playgroud)

但得到:'String'不能转换为[String]

arrays xcode dictionary ios swift

235
推荐指数
9
解决办法
15万
查看次数

标签 统计

arrays ×1

dictionary ×1

ios ×1

swift ×1

xcode ×1