I’m new to learning Objective C and I’m following some online tutorials, I seemed to be keeping up fine and then 26 videos in I’m a little confused. X-Code keeps throwing me an error for an undeclared identifier.
In Person.h I have written:
#import <Foundation/Foundation.h>
@interface Person : NSObject
-(void) dateAge:(int)a withIncome:(int)i;
@end
In Person.m I have written:
#import "Person.h"
@implementation Person
-(void) dateAge:(int)a withIncome:(int)i {NSLog(@"You can date girls %i years old and above", (dateAge/2+7) - (i/100000));}
@end
Person.m is where I am being thrown an error, I’m using the latest version of x-code and the tutorials are a year or so old, I don’t know if that could be it?
main.m just says:
#import <Foundation/Foundation.h>
#import "Person.h
int main(int argc, const char * argv[])
{
@autoreleasepool {
Person *bucky = [[Person alloc]init];
[bucky dateAge:65 withIncome:300000];
}
return 0;
}
Use
ainstead ofdateAgewhich is the declared variable name here,