ios - How do I identify the cause of a "no attribute was found" exception? -
i followed steps in restkit documentation adding project when try start app stops @ line in application:application didfinishlaunchingwithoptions::
entitymapping.identificationattributes = @[@"_id"]; the code before is:
nsurl *modelurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"mymodel" oftype:@"momd"]]; nsmanagedobjectmodel *managedobjectmodel = [[[nsmanagedobjectmodel alloc] initwithcontentsofurl:modelurl] mutablecopy]; rkmanagedobjectstore *managedobjectstore = [[rkmanagedobjectstore alloc] initwithmanagedobjectmodel:managedobjectmodel]; // init core data stack [managedobjectstore createpersistentstorecoordinator]; nspersistentstore __unused *persistentstore = [managedobjectstore addinmemorypersistentstore:&error]; nsassert(persistentstore, @"faild add persistent store: %@", error); [managedobjectstore createmanagedobjectcontexts]; // set default shared store instance [rkmanagedobjectstore setdefaultstore:managedobjectstore]; // configure object manager rkobjectmanager *objectmanager = [rkobjectmanager managerwithbaseurl:[nsurl urlwithstring:@"http://localhost:9090"]]; objectmanager.managedobjectstore = managedobjectstore; [rkobjectmanager setsharedmanager:objectmanager]; rkentitymapping *entitymapping = [rkentitymapping mappingforentityforname:@"pool" inmanagedobjectstore:managedobjectstore]; [entitymapping addattributemappingsfromdictionary:@{ @"id": @"_id", @"about_url": @"abouturl", @"closed": @"closed", @"created_on": @"createdon" }]; entitymapping.identificationattributes = @[@"_id"]; the exception getting thrown in rkentitymapping.m on line 100 (if (!attribute) [nsexception raise:nsinvalidargumentexception format:@"invalid attribute '%@': no attribute found given name in '%@' entity.", attributeorname, [entity name]];) part of rkarrayofattributesforentityfromattributesornames.
when po [entity name] says "pool" have pool entity in .xcdatamodeld.
where else might cause of error?
add id property pool entity.
note: naming property id work, recommend changing not objective-c keyword.
Comments
Post a Comment