PDA

View Full Version : 2008-07-13 18:25:21.027 RaiseMan[9684:10b] *** -[NSUserDefaults setObject:forKey:]: A




NSNick
Jul 13, 2008, 05:33 PM
What does this error mean


2008-07-13 18:25:21.027 RaiseMan[9684:10b] *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '(
<Person: 0x18ecc0>
)' of class 'NSCFArray'.


in relation to this code


#import <Cocoa/Cocoa.h>

@interface MyDocument : NSDocument {
NSMutableArray *employees;
}
-(void)setEmployees:(NSMutableArray *)a;
@end



#import "MyDocument.h"


@implementation MyDocument

-(id)init
{
[super init];
employees = [[NSMutableArray alloc] init];
return self;
}

-(void)dealloc
{
[self setEmployees:nil];
[super dealloc];
}

-(void)setEmployees:(NSMutableArray *)a
{
if (a == employees)
return;

[a retain];
[employees release];
employees = a;
}

@end



#import <Foundation/Foundation.h>


@interface Person : NSObject {
NSString *personName;
float expectedRaise;
}

@property (readwrite, copy) NSString *personName;
@property (readwrite) float expectedRaise;
@end


#import "Person.h"


@implementation Person

-(id)init
{
[super init];
expectedRaise = 5.0;
personName = @"New Person";
return self;
}

-(void)dealloc
{
[personName release];
[super dealloc];
}

@synthesize personName;
@synthesize expectedRaise;
@end



Darkroom
Jul 13, 2008, 06:30 PM
hey... i've noticed you're reading cocoa programming (3rd)... not sure if you know already, but there are solutions on their website (bignerdranch.com) that you can download and compare to your own code if you're having problems (although some of the solutions are not exactly as they are written in the book)... that being said, i still think it good practice to write the code out yourself following the book so you can get use to some of the syntax, etc..

also, you should use the "[ code ]" "[ /code ]" tags when you post code on this board... it makes it easier to read...

Mac Player
Jul 13, 2008, 06:32 PM
Most likely the error is in the bindings you did on interface builder.