ios - No visible @interface for primitive accessor -


i'm trying implement getter method simple transient property. transient property fullname property. typical example of fullname = firstname + lastname.

i'm developing ios app (just in case related works differently on os x)

following 'mastering core data' wwdc 2010 keynote i've created category person nsmanagedobject subclass. in category i've added 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 xcode , has fullname property , implementation @dynamic.

when try compile project error category saying "no visible @interface 'person' declares selector 'primitivefullname'".

why i'm getting error when apple documentation says "for example, given entity attribute firstname, core data automatically generates firstname, setfirstname:, primitivefirstname, , setprimitivefirstname:." ??

the error compile error, not warning

should special have primitive accessors generated?

primitivefullname , setprimitivefullname generated automatically in runtime. in compile time, compiler cannot find these methods. suppress compile error when invoke these methods, should declare prototype of these methods.

if when in 2010, objective-c compiler said warnings invoke undeclared methods. after arc introduced, objective-c compiler disallow invoking such undeclared methods.

like below:

@interface person (primitiveaccessors)  - (nsstring *)primitivefullname; - (void)setprimitivefullname:(nsstring *)newname;  @end  @implementation person (transientproperties)  - (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; }  @end 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -