3

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?

Steve McLeod
  • 51,737
  • 47
  • 128
  • 184

1 Answers1

3

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:.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
  • What about when I override the getter/setter methods of my `synthesised`? In getter and setter I am allowed to directly access `_properties` right? – hashier Nov 28 '13 at 00:16