I have an exception bad access code 2, when i am inserting new entity in core data.
class func createInManagedObjectContext(moc: NSManagedObjectContext, fuel_id: Int, fuel_name: String, price: Double) -> Fuel
{
var fuel = NSEntityDescription.insertNewObjectForEntityForName("GasStation", inManagedObjectContext: moc) as Fuel //exception - EXC_ARM_BREAKPOINT
moc.performBlockAndWait { () -> Void in
fuel.fuel_id = fuel_id
fuel.fuel_name = fuel_name
fuel.price = price
}
// dispatch_async(dispatch_get_main_queue(), { () -> Void in
// fuel.fuel_id = fuel_id
// fuel.fuel_name = fuel_name
// fuel.price = price
//
// })
return fuel
}
and
if let prices = info["prices"] as? NSArray {
for price in prices {
let fuelId : Int = price["fuel_id"] as Int
var fuelPriceString : String = price["price"] as String
let fuelName : String = price["fuel_name"] as String
var fuelPrice : Double = NSString(string:fuelPriceString).doubleValue
println(managedObjectContext)
var fuel =
Fuel.createInManagedObjectContext(managedObjectContext!,fuel_id: Int64(fuelId), fuel_name: fuelName, price:fuelPrice)// exception
fuelSet.append(fuel)
}
println(fuelSet)
}
I tried to see if context is nil, but it has address. i read some articles about zombies tool for detecting what exact exception u have and why, but there is no instructions. Can someone help me, cause i am really stuck?