ios - EXC_BAD_ACCESS when accessing computed property of NSManagedObject -
i have defined class has calculated property. when try access property in code, exc_bad_access
. set breakpoint in getter of property , noticed never called. don't know causing this. can access other properties of object.
here code
import uikit import coredata @objc(person) class person: nsmanagedobject { struct keys { static let name = "name" static let profilepath = "profile_path" static let movies = "movies" static let id = "id" } @nsmanaged var name: string @nsmanaged var id: nsnumber @nsmanaged var imagepath: string? @nsmanaged var movies: [movie] override init(entity: nsentitydescription, insertintomanagedobjectcontext context: nsmanagedobjectcontext?) { super.init(entity: entity, insertintomanagedobjectcontext: context) } init(dictionary: [string : anyobject], context: nsmanagedobjectcontext) { let entity = nsentitydescription.entityforname("person", inmanagedobjectcontext: context)! super.init(entity: entity, insertintomanagedobjectcontext: context) name = dictionary[keys.name] as! string id = dictionary[keys.id] as! int imagepath = dictionary[keys.profilepath] as? string } var image: uiimage? { { return themoviedb.caches.imagecache.imagewithidentifier(imagepath) } set { themoviedb.caches.imagecache.storeimage(image, withidentifier: imagepath!) } } }
this how try access image property ,
execution interrupted, reason: exc_bad_access (code=1, address=0x20)
when actor.image
. actor
object of person
class , initialized. put breakpoint in getter image property , never called.
if let localimage = actor.image { cell.actorimageview.image = localimage } else if actor.imagepath == nil || actor.imagepath == "" { cell.actorimageview.image = uiimage(named: "personnoimage") }
what doing wrong?
i figured out problem, had not set class entity in data model inspector. solved it
Comments
Post a Comment