[CORE DATA] Custom accessors question
[CORE DATA] Custom accessors question
- Subject: [CORE DATA] Custom accessors question
- From: Aurélien Hugelé <email@hidden>
- Date: Mon, 13 Feb 2006 14:25:17 +0100
Hi list
i prefer implementing core data accessors to get Xcode completion,
and many compilation checking instead of using valueForKey/
mutableSetValueForKey.
Thanks to Xcode, I can get the implementation code quickly by right
clicking on any of my properties and asking for "Copy Method
Implementations to Clipboard". That's nice.
But something puzzle me, why is the the "get" accessors not implemented?
asking for implementations of my "persons" to-many relation ship
gives me:
- (void)addPersonsObject:(GCMKCorePerson *)value
{
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value
count:1];
[self willChangeValueForKey:@"persons"
withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey: @"persons"] addObject: value];
[self didChangeValueForKey:@"persons"
withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[changedObjects release];
}
- (void)removePersonsObject:(GCMKCorePerson *)value
{
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value
count:1];
[self willChangeValueForKey:@"persons"
withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey: @"persons"] removeObject: value];
[self didChangeValueForKey:@"persons"
withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
[changedObjects release];
}
why don't the implementations contains:
-(NSMutableSet*)persons
{
NSMutableSet* value;
[self willAccessValueForKey:@"persons"]
value = [self primitiveValueForKey:@"persons"];
[self didAccessValueForKey:@"persons"];
return value;
}
???
*MUST* I *ONLY* use [myObject mutableSetValueForKey:@"persons"] to
get the persons ? or is my implementation above correct ?
what happens if I use [myObject mutableSetValueForKey:@"persons"]
accessor, but have implemented -(NSMutableSet*)persons above ? will
my custom accessor be called?
thanks
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden