【发布时间】:2016-06-24 00:48:18
【问题描述】:
我知道这将是超级初级的,但我有这段代码:
var labels: [String]?
func initVC(image: Images){
self.image = image
let tempLabels = image.label?.allObjects as! [Labels]
for i in 0..<tempLabels.count{
labels?.append(tempLabels[i].label!)
}
}
labels 在公共范围内,所以函数应该可以访问它,但是当循环运行时,labels 仍然是 nil,没有元素。
当我在调试过程中 po 时,tempLabels 与我预期的一样,包含 2 个字符串元素。
我很确定这是一个非常简单的问题,但我想我现在刚刚解决了。
【问题讨论】: