Steve McLeod
Steve McLeod

Reputation: 52468

Is this object KVC-compliant?

I'm trying to understand how to use Bindings in Xcode. I have this class:

#import <Foundation/Foundation.h>

@interface OddsItem : NSObject {
    NSMutableDictionary *properties;
}
@property(nonatomic, retain) NSMutableDictionary *properties;

@end

and

#import "OddsItem.h"


@implementation OddsItem {

}
@synthesize properties;

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

@end

Is this KVC-compliant? The examples I've found seem to be from before the days of synthesized properties.

If it isn't KVC-compliant what must I do to make it so?

Upvotes: 3

Views: 1842

Answers (1)

David R&#246;nnqvist
David R&#246;nnqvist

Reputation: 56635

The generated methods from @synthesized are KVO-comliant.

As long as you change the property using the setter method it will be KVO-compliant.

If however you change the instance variable directly it won't be. In that case you will have to manually call willChangeValueForKey: and didChangeValueForKey:.

Upvotes: 3

Related Questions