I'm working on exercise 3 on page 76 in Apple's developer pdf in the class categories and extensions section, "Programming with Objective C", found here: (https://developer.apple.com/library/mac/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html)
my XYZPerson header looks like this:
#import <Foundation/Foundation.h>
@interface XYZPerson : NSObject
@property (readonly) NSNumber *height;
@property (readonly) NSNumber *weight;
-(NSNumber *)measureHeight;
-(NSNumber *)measureWeight;
@end
My implementation file looks like this:
#import "XYZPerson.h"
@property (readwrite) NSNumber *height;
@property (readwrite) NSNumber *weight;
@end
/////////////////////
@implementation XYZPerson
-(NSNumber *)measureHeight{
if(!_height){
_height = [[NSNumber alloc] init];
}
return _height;
}
-(NSNumber *)measureWeight{
if(!_weight){
_weight = [[NSNumber alloc] init];
}
return _weight;
}
@end
And then in my main file I have:
#import <Foundation/Foundation.h>
#import "XYZPerson.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
XYZPerson *aPerson = [[XYZPerson alloc] init];
[aPerson setHeight: [NSNumber numberWithInt:72] ];
[aPerson setWeight: [NSNumber numberWithInt:190] ];
NSLog(@"%@ %@",[aPerson measureHeight],[aPerson measureWeight]);
}
return 0;
}
There might be more than one error unrelated to the issue I brought up, I'm a huge novice at Objective C right now. The exact compiler error I am getting is on the line that says,
[aPerson setHeight: [NSNumber numberWithInt:72] ];
The compiler error reads, "ARC Semantic Issue. No visible @interface for 'XYZperson' declares the selector 'setWeight:'.