• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[CORE DATA] Custom accessors question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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


  • Follow-Ups:
    • Re: [CORE DATA] Custom accessors question
      • From: email@hidden
  • Prev by Date: NSTableView
  • Next by Date: Class Memory Management
  • Previous by thread: NSTableView
  • Next by thread: Re: [CORE DATA] Custom accessors question
  • Index(es):
    • Date
    • Thread