I'm trying to implement a getter method for a simple transient property. The transient property is a fullName property. Typical example of fullName = firstName + lastName.
I'm developing an iOS app (just in case something related works differently on OS X)
Following the 'Mastering Core Data' WWDC 2010 Keynote I've created a category for my Person NSManagedObject subclass. In that category I've added the following method:
- (NSString *)fullName {
[self willAccessValueForKey:@"fullName"];
NSString *fullName = [self primitiveFullName];
[self didACCessValueForKey:@"fullName"];
if (fullName == nil) {
fullName = [NSString stringWithFormat:@"%@ %@", self.firstName, self.lastName];
[self setPrimitiveFullName:fullName];
}
return fullName;}
Person class has been created automatically by Xcode and has the fullName property and its implementation with @dynamic.
When I try to compile the project I get an error for this category saying "No visible @interface for 'Person' declares selector 'primitiveFullName'".
Why I'm getting this error when Apple documentation says "For example, given an entity with an attribute firstName, Core Data automatically generates firstName, setFirstName:, primitiveFirstName, and setPrimitiveFirstName:." ??
The error is a compile error, not a warning
Should I something special to have the primitive accessors generated?