Reputation: 64834
I'm overriding a Core Data setter with this code:
- (void)setName:(NSString *)newName
{
[self willChangeValueForKey:@"name"];
[self setPrimitiveName:newName];
[self didChangeValueForKey:@"name"];
}
It works perfectly, however I'm getting the a compiler warning:
warning: 'MyClass' may not respond to '-setPrimitiveName:newName:'
Is this correct? If so, can I suppress this warning ? Thanks
Upvotes: 0
Views: 336
Reputation: 7272
Compiler warnings suck: [self setPrimitiveValue:newName forKey:@"name"];
Upvotes: 2
Reputation: 39905
Yes, that is the correct way to do it. The setPrimitiveName:
method will be generated automatically by Core Data. To get rid of the warning, add a category interface at the top of your implementation file which declares primitive accessors.
// MyClass.m
@interface MyClass (CoreDataPrimitiveAccessors)
- (void)setPrimitiveName:(NSString *)newName;
- (NSString *)primitiveName;
@end
// class implementation goes here
Upvotes: 2
Reputation: 975
You have to declare the method in the header (MyClass.h)
- (void)setPrimitiveName:(NSString *)newName;
Upvotes: -1