作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
代码说完全没问题,没有错误,但是当我去运行模拟器的时候,会出现这样的字样:
(Swift.LazyMapCollection < Swift.Dictionary < Swift.String, Swift.String > (_base:[ ]
我正在尝试创建一个显示报价的报价应用。
这是导入 Plist 的代码:
import Foundation
struct ImportList {
let path: String
init(FileName: String) {
self.path = NSBundle.mainBundle().pathForResource("\(FileName)", ofType:"plist")!
}
var dict: Dictionary<String, String> {
return NSDictionary(contentsOfFile: path)! as! Dictionary
}
var array: Array<AnyObject> {
return [String](arrayLiteral: String(dict.keys) { $0 as String})
}
func count() -> Int {
return array.count
}
}
谢谢。
最佳答案
在这种情况下不要使用arrayLiteral
,只需使用Array()
:
var array: Array<AnyObject> {
return Array(dict.keys)
}
它将惰性集合安全地转换为实际数组。
关于string - (Swift.LazyMapCollection<Swift.Dictionary<Swift.String, Swift.String>(_base :[ ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36874973/
有人能描述一下这个操作的实际作用吗?据我了解,它是一张 map ,但 values 和 reduce 的实际含义是什么。据我了解,它将闭包作为参数,对吗? let result = self.myDi
我在获取所有字典键时遇到问题。 当我调用 .keys 时,出现如下错误。 而且我不知道如何解决。 谢谢。 错误: Value of optional type 'LazyMapCollection,
代码说完全没问题,没有错误,但是当我去运行模拟器的时候,会出现这样的字样: (Swift.LazyMapCollection (_base:[ ] 我正在尝试创建一个显示报价的报价应用。 这是导入
我是一名优秀的程序员,十分优秀!