Segmentation Fault: 11 - Xcode 6.3

倖福魔咒の 提交于 2019-12-05 10:24:17

Solved it. Problem was two things: 1) Converting to Double 2) Handling an empty array

Converting to Double

Changed from var lat: Double? = d["lat"].doubleValue to var lat: Double? = Double(d["lat"].doubleValue)

Handling an empty array

Changed from

let brands = d["brands_unfiltered"].arrayValue {
if brands == [] {
    // Do nothing (empty)
}
else{
    // Do stuff
}

To

if let brands = d["brands_unfiltered"].arrayValue as Array! {
     // Do stuff
}

To find the root cause I deactivated larges part of the code until I found what got the archiving not to function. Thereafter the solution was pretty straight forward. Hope this helps someone else struggling with the same error.

I found the code that cause my "Archive" action to fail with this error "Command failed due to signal: Segmentation fault: 11"

When I use the indexPath in the cellForRowAtIndexPath function, I need to put an exclamation mark (i.e indexPath! instead of indexPath). However, I still puzzled by why there is such error if I omit the exclamation mark. Does anyone know the reason?

    override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {

            // code to get cell, etc

            let thumbnailImage = self.userPhotos?.getFromCacheOrDownload(username,
                circle: team.circle(), delegate: self, indexPath: indexPath!)
            cell.userPhotoImageView.image = thumbnailImage

            return cell
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!