2011-08-11 28 views
2

私はこのmanagedObjectのサブクラスを持っています。位置はNSPointの位置です。 XIBでは、私はこのNSPointを含むNSValueにバインドの問題

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

つの表示position.x値やその他の表示position.yのような2 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

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 

私はこのコードを試してみてください。

-(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 econd KVC setValueのは、任意のヘルプは感謝している理由、私は理解していない

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

上記と同じメッセージを持つ第三のクラッシュに動作します。

答えて

0

NSValueオブジェクトは変更できません。 NSValueプロパティを変更するには、新しいNSValueオブジェクトを作成し、それをプロパティに割り当てる必要があります。

関連する問題