core data - How to set the NSManagedObjectContext for MR_findFirst? -


i use magicalrecord coredata store. have statement generating multiple crashes different users when statement executed:

preferencedata *prefdatafound = [preferencedata mr_findfirst]; 

the error is:

+entityforname: nil not legal nsmanagedobjectcontext parameter searching entity name 'preferencedata'

coming sequence of calls (from crashlytics):

1   libobjc.a.dylib objc_exception_throw + 30 2   coredata +[nsentitydescription entityforname:inmanagedobjectcontext:] + 104 3   salonbook nsmanagedobject+magicalrecord.m line 91     +[nsmanagedobject(magicalrecord) mr_entitydescriptionincontext:] 4   salonbook nsmanagedobject+magicalrequests.m line 19     +[nsmanagedobject(magicalrequests) mr_createfetchrequestincontext:] 5   salonbook nsmanagedobject+magicalfinders.m line 79     +[nsmanagedobject(magicalfinders) mr_findfirstincontext:] 6   salonbook nsmanagedobject+magicalfinders.m line 86     +[nsmanagedobject(magicalfinders) mr_findfirst] 7   salonbook subviewgrid.m line 37     -[subviewgrid drawrect:] 

all of indicates me there no valid context mr_findfirst call; oher using *mr_findfirstwithpredicate:* (for have no predicate, want first , record), can fix this?

you can call

preferencedata *prefdatafound = [preferencedata mr_findfirstincontext:context]; 

with current context, instead of relying on magical record determine current context magically.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -