iphone - Adding objects in Core Data -
i trying familiar core data , had xcode create subclasses of nsmanagedobject me. 1 addressannotation has information location street, zip, address, etc. other is:
map : nsmanagedobject @property (nonatomic, retain) nsstring * name; @property (nonatomic, retain) nsset *locations; - (void)addlocationsobject:(addressannotation *)value; - (void)removelocationsobject:(addressannotation *)value; - (void)addlocations:(nsset *)values; - (void)removelocations:(nsset *)values;
when want add location map, do:
- (void)insertlocationintomap:(map *)map { [map addlocationsobject:self.address];
i nslogged map object , address object , both have values in it. when try adding object existing map object, not seem added. output of map logged is:
<map: 0x7087480> (entity: map; id: 0x7084ff0 <x-coredata://8d6d7849-e7ec-48a3-ba95-c082d09e5d6d/map/p1> ; data: { locations = "<relationship fault: 0x768e4e0 'locations'>"; name = asdf; })
if create new map, , call insertlocationintomap:, addressannotation object added. map logged is:
<map: 0x767dee0> (entity: map; id: 0x767d2d0 <x-coredata://8d6d7849-e7ec-48a3-ba95-c082d09e5d6d/map/p5> ; data: { locations = ( ); name = asdfasdf; })
am doing wrong in adding addressannotation maps object? working when didn't use subclasses of nsmanagedobject , using setvalue:forkey: everywhere, thought more intuitive after got used it. thanks!
the first log shows fault relationship. tells nothing objects in relationship. should log addressannotation.map
relationship. one-to-many or many-to-many relationship?
and ultimately, if want print out objects related, should use fetch request fetch objects in locations relationship (@"self.map == %@"
addressannotation
entity %@ substituted map
instance interested in).
Comments
Post a Comment