且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

分段故障:11 - Xcode 6.3

更新时间:2022-10-15 16:29:06

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.