0
我收到一個Quartz Composer應用程序,在Xcode 5中製作的應用程序。該應用程序有幾個參數發佈在.qtz文件中。我想手動添加UI滑塊/按鈕來控制參數,但我有問題。我將發佈編輯後的片段以供參考。KeyValue綁定NSNumber與Quartz Composer
我試圖滑塊綁定到此的AppDelegate:
在AppDelegate.h:
int amount;
@property int amount;
在AppDelegate.m文件;
@synthesize amount;
-(void) awakeFromNib{
amount = 50;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification{
[QCView [NSNumber numberWithInt:amount] forInputKey:@"inputNumber"];
我的問題:awakeFromNib不更新滑塊以「50」,並且量不是由NSNumber的「看到」。
我聯繫了這個例子的作者,他回答說:
「你不能看到它,因爲你不‘聽’到‘量’。改變你要問:
[self addObserver:self forKeyPath:@"amount" options:NSKeyValueObservingOptionNew context:NULL];"
」所以,你必須在「添加observeValueForKeyPath東西.. 」功能:
else if ([keyPath isEqualToString:@"amount"])
{
NSLog(@"AMOUNT = %d", self.amount);
[myQCView [NSNumber numberWithInt:amount] forInputKey:@"inputNumber"];
}"
我想這一點,並獲得兩個錯誤: 。意外的接口名稱'NSNumber':預期表達式 。解析問題預期']'要匹配''''''是否有一種簡單的方法可以將滑塊綁定到NSNumber?