我刚刚在Apple开发人员的推荐下更新到最新版本的Xcode。结果如下,以下代码在过去三个月中一直在运行,现在它会生成以下错误:"致命错误:在解包可选值时意外发现nil (lldb)
以下代码一直正常运行:
var uploadImage = [PFFile]()
var xxxxxxxxxxinfo = [String]()
var xxxxxxxxxxinfo = [String]()
var xxxxxxxxxxinfo = [String]()
var xxxxxxxxxxinfo = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let query = PFQuery(className: "PropertyImage")
query.orderByDescending("createdAt")
query.findObjectsInBackgroundWithBlock { (posts: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// Successfully gathered images
for post in posts! {
self.uploadImage.append(post["imageFile"] as! PFFile)
self.xxxxxxxxxxinfo.append(post["xxxxxfield"] as! String)
self.xxxxxxxxxxinfo.append(post["xxxxxfield"] as! String)
self.xxxxxxxxxxinfo.append(post["xxxxxfield"] as! String)
self.xxxxxxxxxxinfo.append(post["xxxxxfield"] as! String)
}
// Reload TableView
self.propertyAlertTable.reloadData()
}else {
print(error)
}
}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return uploadImage.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let singleCell: CustomCellProperty = tableView.dequeueReusableCellWithIdentifier("PropertyAlertCell") as! CustomCellProperty
// Retrieve text for Image
singleCell.xxxxxxxxxxLabel.text = xxxxxinfo[indexPath.row]
singleCell.xxxxxxxxxxLabel.text = xxxxxinfo[indexPath.row]
singleCell.xxxxxxxxxx.text = xxxxxinfo[indexPath.row]
singleCell.xxxTextView.text = xxxxxinfo[indexPath.row]
// Retrieve Image File
uploadImage[indexPath.row].getDataInBackgroundWithBlock { (imageData: NSData?, error: NSError?) -> Void in
if imageData != nil {
let image = UIImage(data: imageData!)
singleCell.displayImageView.image = image
}else {
print(error)
}
}
return singleCell
}
除了[" imageFile"]之外,所有内容都很好地上传到Parse.com,因此它不再填充TableView屏幕。
尊敬地,我不需要解释,我明白为什么它没有发生。但是因为这对我来说都是新的,我不明白如何重新编码以下行。
self.uploadImage.append(post["imageFile"] as! PFFile)
生成错误:
"致命错误:在展开Optional值时意外发现nil (lldb)
我只需要知道如何重写该代码。再次记住,这在升级之前已经工作了几个月。