No visible @interface error - help :)


#1

I’m getting the mentioned error when I try to add the code suggested in the text. Specifically the message

[a setHolder:self];. I’ve included the relevant files, but can’t figure out where I went wrong. I am synthesizing the holder value in the Asset.m file…so I’m not sure what’s wrong. Any help is much appreciated.

Employee.m file

//  Employee.m
#import "Employee.h"
#import "Asset.h"
@implementation Employee
@synthesize employeeID;

-(void)addAssetsObject:(Asset *)a
{
    if(!assets) {
        assets = [[NSMutableArray alloc]init];
    }
    [assets addObject:a];
    [a setHolder:self];
}

-(unsigned int)valueOfAssets
{
    unsigned int sum = 0;
    for (Asset *a in assets) {
        sum += [a resaleValue];
    }
    return sum;
}


-(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

Asset.h file

//  Asset.h
//  MemoryLeaks

#import <Foundation/Foundation.h>
@class Employee;

@interface Asset : NSObject
{
    NSString *label;
    Employee *holder;
    unsigned int resaleValue;
}

@property (strong) NSString *label;
@property (strong) Employee *holder;
@property unsigned int resaleValue;
@end

Asset.m

//  Asset.m
#import "Asset.h"
#import "Employee.h"
@implementation Asset
@synthesize label, resaleValue, holder;

-(NSString *)description
{
    if ([self holder]){
        return [NSString stringWithFormat:@"<%@: $%d, assigned to %@>", [self label],[self resaleValue],[self holder]];
    }else{
        return [NSString stringWithFormat:@"<%@: $%d unassigned>", [self label], [self resaleValue]];
    }
    
}

-(void)dealloc{
    NSLog(@"deallocating %@", self);
}

@end

Employee.h file

//  Employee.h
#import "Person.h"
@class Asset;

@interface Employee : Person
{
    int employeeID;
    NSMutableArray *assets;
}

@property int employeeID;
-(void)addAssetsObject:(Asset *)a;
-(unsigned int)valueOfAssets;

@end