In have an NSManagedObject subclass:
@interface ManagedActivityAmount : NSManagedObject
@property (nonatomic, retain) NSNumber * distance;
@property (nonatomic, retain) NSNumber * duration;
@property (nonatomic, retain) NSSet *sets;
@end
@interface ManagedActivityAmount (CoreDataGeneratedAccessors)
- (void)addSetsObject:(ManagedPowerSet *)value;
- (void)removeSetsObject:(ManagedPowerSet *)value;
- (void)addSets:(NSSet *)values;
- (void)removeSets:(NSSet *)values;
@end
I encounter a problem in keeping a reference to an object that i added to the sets relationship using the:
- (void)addSetsObject:(ManagedPowerSet *)value;
the ManagedPowerSet object was successfully added to the ManagedActivityAmount sets property, and I’m assuming it’s retain count is 1 due to this (the actual object was autoreleased before that so the retain count was 0 before adding it to the set). am I correct? am I missing something?
I’m assigning the ManagedPowerObject to another instance variable of the view controller (this is a private instance variable, not a retained property) but I can’t seem to access it later. should I retain it? i’m just about to do so and check, but I really want to understand we it wasn’t retained in the first place.
thanks 🙂
So i wasn’t missing anything, the retain count assumptions were correct, no retain was needed since the object outlives the controller, if it were a property it should have been assigned..
the problem was really stupid on my part, i didn’t allocate something else that made it looked like the object was lost, though actually it wasn’t.
as for the debugger and what seems as if the two pointers that were supposed to point to the same address but weren’t – i have no clue why this happens, i guess the xcode debugger has some delays..