I am trying to get values from NSDictionary, but here is two place where is EXC_BAD_INSTRUCTION with fatal error. And I'm interesting in how to get values from NSDictionary without this problems
private func checkResponseResult(responseResult: NSDictionary) {
// Initialize Group object and [Group] arrays
println(responseResult)
for item in responseResult {
//create object of Group, set attributes, add to Array
var itemKey = item.key as NSString
if itemKey.isEqualToString("error") {
// Error received, user has no groups assigned
println("Error: \(item.value)")
} else {
// Groups values received
println("Core Data insert / group id: \(item.key)")
var gr:Group = Group()
var name = "name"
var latitude = "latitude"
var longitude = "longitude"
var project = "project"
var radius = "raidus"
var val = item.value[longitude]
//return nil
println(val)
//return false
println(val==nil)
gr.id = itemKey.integerValue
gr.name = item.value[name] as String
gr.latitude = item.value[latitude] == nil || item.value[latitude] as NSNull == NSNull() ? 0.0 : item.value[latitude] as NSNumber
//fatal error: unexpectedly found nil while unwrapping an Optional value
gr.longitude = item.value[longitude] == nil || item.value[longitude] as NSNull == NSNull() ? 0.0 : item.value[longitude] as NSNumber
gr.project = item.value[project] as String
//fatal error: unexpectedly found nil while unwrapping an Optional value
gr.radius = item.value[radius] == nil || item.value[radius] as NSNull == NSNull() ? 0.0 : item.value[radius] as NSNumber
}
}
}
NSDictionary is here
{
30 = {
latitude = "<null>";
longtitude = "<null>";
name = mtmb;
project = "pr_mtmb";
radius = "<null>";
};
}