Now that Xcode4 is publicly available I'm moving this question out of Apple's secret dev forum:
Can someone explain why the code generated in the following procedure is different than in Xcode3? Is the code better or might this be a bug?
I use Core Data custom managed classes and this was the procedure I followed in Xcode3:
Now, in Xcode4, I THINK this is how to do it, but I'm not sure because it generates different code:
The code it is generating is different for a number of reasons:
For example, Xcode3 would have generated this code in the HEADER file:
@interface SampleEntity (CoreDataGeneratedAccessors)
- (void)addChildObject:(Child *)value;
- (void)removeChildObject:(Child *)value;
- (void)addChild:(NSSet *)value;
- (void)removeChild:(NSSet *)value;
@end
Now, Xcode4 generates this code in the IMPLEMENTATION file:
@implementation SampleEntity
@dynamic children;
- (void)addChildObject:(Child *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
[self willChangeValueForKey:@"children" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"children"] addObject:value];
[self didChangeValueForKey:@"children" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[changedObjects release];
}
Can someone weigh in on why this is different? Xcode4 code sense does not like this new way of generating NSManagedObject subclasses.