I am getting this error on my heightInMeters, weightInKilos, label and resaleValue setters. The error says 'Semantic Issue property X is not found on object of type BNREmployee. My code is below. I would be grateful for anyone to look through it and give me a solution or if anyone could share their code. Thanks.
main.m
[code]#import <Foundation/Foundation.h>
#import “BNRAsset.h”
#import “BNREmployee.h”
#import "BNRPerson.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
//create an array of BNREmployee objects
NSMutableArray *employees = [[NSMutableArray alloc]init];
for (int i = 0; i < 10; i++) {
//Create an instance
BNREmployee *mikey = [[BNREmployee alloc]init];
//Give values to the variables
mikey.weightInKilos = 90 + 1;
mikey.heightInMeters = 1.8 - i/10.0;
mikey.employeeID = i;
//Put in the array
[employees addObject:mikey];
}
//Creat 10 assets
for (int i = 0; i < 10; i++) {
//Create an asset
BNREmployee *asset = [[BNRAsset alloc]init];
NSString *currentLabel = [NSString stringWithFormat:@"Laptop %d", i];
asset.label = currentLabel;
asset.resaleValue = 360 + i * 17;
//Create a random number between 0-9 inclusive
NSUInteger randomIndex = random() % [employees count];
//Find that employee
BNREmployee *randomEmployee = [employees objectAtIndex:randomIndex];
//Assign the asset to the employee
[randomEmployee addAsset:asset];
}
NSLog(@"Employees %@", employees);
NSLog(@"Giving up ownership of one employee");
[employees removeObjectAtIndex:5];
NSLog(@"Giving up ownership of arrays");
employees = nil;
}
return 0;
}
[/code]
BNRPerson.h
#import <Foundation/Foundation.h>
@interface BNRPerson : NSObject
@property (nonatomic) float heightInMeters;
@property (nonatomic) int weightInKilos;
//BNRPerson has a method that calculates the Body Mass Index
- (float)bodyMassIndex;
@end
BNRPerson.m
[code]#import “BNRPerson.h”
@implementation BNRPerson
- (float)bodyMassIndex
{
float h = [self heightInMeters];
return [self weightInKilos] / (h * h);
}
@end[/code]
BNREmployee.h
@interface BNREmployee : NSObject
@property (nonatomic) unsigned int employeeID;
@property (nonatomic) NSDate *hireDate;
@property (nonatomic, copy) NSArray *asset;
- (double)yearsOfEmployment;
- (void)addAsset:(BNRAsset *)a;
- (unsigned int)valueOfAssets;
@end[/code]
BNREmployee.m
[code]#import "BNREmployee.h"
#import "BNRAsset.h"
@interface BNREmployee ()
{
NSMutableArray *_assets;
}
@property (nonatomic) unsigned int officeAlarmCode;
@end
@implementation BNREmployee
//Accessors for assets properties
- (void)setAssets:(NSArray *)a
{
_assets = [a mutableCopy];
}
- (NSArray *)assets
{
return [ _assets copy];
}
- (void)addAsset:(BNRAsset *)a
{
//Is assets nil?
if (!_assets) {
//create the array
_assets = [[NSMutableArray alloc]init];
}
[_assets addObject:a];
}
- (unsigned int)valueOfAssets
{
//Sum up the resale value of the assets
unsigned int sum = 0;
for (BNRAsset *a in _assets){
sum += [a resaleValue];
}
return sum;
}
- (double)yearsOfEmployment
{
if (self.hireDate) {
NSDate *now = [NSDate date];
NSTimeInterval secs = [now timeIntervalSinceDate:self.hireDate];
return secs / 31557600.0;
} else {
return 0;
}
}
- (float)bodyMassIndex
{
float normalBMI = [super bodyMassIndex];
return normalBMI * 0.9;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<Employee %d: $%d in assets>", self.employeeID, self.valueOfAssets];
}
- (void)dealloc
{
NSLog(@"deallocating %@", self);
}
@end
BNRAsset.h
#import <Foundation/Foundation.h>
#import "BNREmployee.h"
@interface BNRAsset : NSObject
@property (nonatomic, copy) NSString *label;
@property (nonatomic) unsigned int resaleValue;
@end
BNRAsset.m
#import "BNRAsset.h"
@implementation BNRAsset
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: $%d>", self.label, self.resaleValue];
}
- (void)dealloc
{
NSLog(@"deallocating %@", self);
}
@end