2
我有這個managedObject
子類,位置表示一個NSPoint。在XIB我想要兩個的NSTextField這樣綁定問題與NSValue包含NSPoint
,其中一個顯示position.x值和其他顯示position.y。我試圖的NSTextField綁定到「selection.position.x」和NSArrayController的的「selection.position.y」的keyPath該管理框架
我得到這個錯誤::
[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key x.
所以我檢查KVC:
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
我試試這個代碼:
-(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 KVC的Econd工作的setValue,具有相同的消息,第三碰撞上述
[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key x.
我不明白爲什麼,任何幫助是讚賞。