I’ve been working through the book with no massive issues so far but for some reason i’m getting a lot of errors when trying to use the BNREmployee class.
This is what is in my main.m:
[code]#import <Foundation/Foundation.h>
#import “BNREmployee.h”
#import “BNRPerson.h”
int main(int argc, const char * argv[])
{
@autoreleasepool {
// create and instance of BNREmployee
BNREmployee *dan = [[BNREmployee alloc] init];
//give the instance variables interesting values using setters
dan.weightInKilos = 100;
dan.heightInMeters =1.75;
dan.employeeID = 12;
dan.hireDate = [NSDate dateWithNaturalLanguageString:@"Feb 27th, 2014"];
//log the instance vars with the getters
float height = dan.heightInMeters;
int weight = dan.weightInKilos;
NSLog(@"I am %.2f meters tall and weigh %d kilos.\n", height, weight);
//log some values using custom methods
float bmi = [dan bodyMassIndex];
NSLog(@"This fat fuck has a BMI of %f", bmi);
}
return 0;
}[/code]
I get errors saying “Property ‘weightInKilos’ is not found on object type BNREmployee *”. I get a similar error for every setter an getter in the code.
If I change BNREmployee *dan = [[BNREmployee alloc]init];
to BNRPerson *dan = [[BNREmployee alloc]init];
those errors disappear for the height and weight methods but are still there for the employee methods.
Is there something that i’m missing here? I assumed that with inheritance I would just be able to call methods from a superclass with no issue, and i’m sure thats what is meant to happen.