2012-08-06 1 views
3

Xcode에서 바인딩을 사용하는 방법을 이해하려고합니다.이 개체는 KVC 호환입니까?

#import <Foundation/Foundation.h> 

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

@end 

#import "OddsItem.h" 


@implementation OddsItem { 

} 
@synthesize properties; 

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

@end 

이이 KVC - 준수 :이 클래스가? 내가 찾은 예들은 합성 된 속성의 시대 이전 인 것 같습니다.

KVC와 호환되지 않는 경우 어떻게해야합니까?

답변

3

@synthesized에서 생성 된 메소드는 KVO-comliant입니다.

setter 메서드를 사용하여 속성을 변경하면 KVO와 호환됩니다.

그러나 인스턴스 변수를 직접 변경하는 경우에는 변경되지 않습니다. 이 경우 수동으로 willChangeValueForKey:didChangeValueForKey:으로 전화해야합니다.

+0

내 'synthesised'의 getter/setter 메서드를 재정의하면 어떨까요? getter와 setter에서는'_properties' 권한에 직접 액세스 할 수 있습니까? – hashier