I'm learning Objective-C.
I'm at the point of creating a simple class but when compiling, after the expected result, I get this errors.
2014-05-08 10:15:47.998 ClassCreation[978:903] This is a method call in the new object!
2014-05-08 10:15:48.007 ClassCreation[978:903] -[Employee setName:]: unrecognized selector sent to instance 0x10010c850
...
terminate called after throwing an instance of 'NSException'
(gdb)
Here it is the Employee.h
#import <Foundation/Foundation.h>
@interface Employee : NSObject
// properties
@property NSString *name;
@property NSDate *hireDate;
@property int employeeNumber;
-(void) someMethod;
@end
Here it is the Employee.m
#import "Employee.h"
@implementation Employee
// matching the method definition that is defined in the interface
-(void) someMethod {
NSLog(@"This is a method call in the new object!");
}
@end
Here it is the main.m
#import <Foundation/Foundation.h>
#import "Employee.h"
int main (int argc, const char * argv[])
{
@autoreleasepool {
// inside here, I instantiate a new object of my new employee class
Employee *fred = [[Employee alloc] init];
// call a method of our new object
[fred someMethod];
// change a property of new object
[fred setName:@"Fred Smith"];
}
return 0;
}
I'm on 10.6.8 with Xcode 4.2