ヒレガス本Chapter7


#import <Cocoa/Cocoa.h>


@interface AppController : NSObject {

	int fido;
}

@property(readwrite, assign) int fido;

//-(int)fido;
//-(void)setFido:(int)x;
-(IBAction)incrementFido:(id)sender;

@end
#import "AppController.h"


@implementation AppController

-(IBAction)incrementFido:(id)sender
{/*
	[self willChangeValueForKey:@"fido"];
	fido++;
	NSLog(@"fido is now %d", fido);
	[self didChangeValueForKey:@"fido"];*/
	[self setFido:[self fido] + 1];
}

-(id)init
{
	[super init];
	[self setValue:[NSNumber numberWithInt:5] forKey:@"fido"];
	NSNumber *n = [self valueForKey:@"fido"];
	NSLog(@"fido = %@", n);
	return self;
}

@synthesize fido;

/*
-(int)fido
{
	NSLog(@"-fido is returning %d", fido);
	return fido;
}

-(void)setFido:(int)x
{
	NSLog(@"-setFido: is called with %d", x);
	fido = x;
}
 */
@end