2011-08-11 5 views
2

managedObject 하위 클래스가 있습니다. 위치는 NSPoint입니다. XIB에서 나는이NSPoint가 포함 된 NSValue에 바인딩 문제가 발생했습니다.

http://s1.postimage.org/rkd74ebo/Schermata_08_2455785_alle_14_13_57.png

하나 개의 디스플레이 position.x 값과 다른 디스플레이 position.y 같은 두 NSTextField있는 원한다. 나는이 오류 : 그래서 내가 확인

[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key x.

을 얻을 "selection.position.x"와

프레임

관리중인 NSArrayController의 "selection.position.y"키 패스로 NSTextField있는 바인딩을 시도 KVC는 :

-(void)awakeFromInsert 
{ 
    [super awakeFromInsert]; 

    self.position = [NSValue valueWithPoint:NSPointFromCGPoint(CGPointZero)]; 

    //[self.position setValue:[NSNumber numberWithFloat:50.0f] forKey:@"x"]; 

    [self setValue:[NSNumber numberWithFloat:1.0f] forKeyPath:@"scale"]; 
    [self setValue:[NSNumber numberWithFloat:10.0f] forKeyPath:@"frame.origin.x"]; 
    [self setValue:[NSNumber numberWithFloat:10.0f] forKeyPath:@"position.x"]; 
} 

첫 번째와 S : -(void)awakeFromInsert에서

Frame.h 

@interface Frame : NSManagedObject { 

@private 

} 

@property (nonatomic, retain) NSNumber * order; 
@property (nonatomic, retain) NSNumber *visible; 
@property (nonatomic, retain) NSValue *position; 
@property (nonatomic, retain) NSNumber *scale; 
@property (nonatomic, retain) Sprite *sprite; 
@property (nonatomic, retain) Resource *resource; 

//test 
@property (nonatomic, retain) NSValue *frame; 

@end 

나는이 코드를 시도 econd KVC setValue 작품, 위의 같은 메시지와 함께 세 번째 충돌

[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key x. 

나는 왜, 어떤 도움을 주셔서 감사합니다 이해가 안돼.

답변

0

NSValue 개체는 변경할 수 없습니다. NSValue 속성을 변경하려면 새 NSValue 개체를 만든 다음 속성에 할당해야합니다.

관련 문제