0

I received an example Quartz Composer app, made in Xcode 5. The App has several parameters published in the .qtz file. I would like to manually add UI sliders / buttons to control the parameters, but am having issues. I will post edited snippets for reference.

I tried to bind a slider to this AppDelegate:

In the AppDelegate.h:

int amount;
@property int amount;

In the AppDelegate.m file;

@synthesize amount;

-(void) awakeFromNib{
amount = 50;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification{
[QCView [NSNumber numberWithInt:amount] forInputKey:@"inputNumber"];

My problems: awakeFromNib does not update the slider to '50', and the amount is not being 'seen' by the NSNumber.

I contacted the author of this example, and he replied;

"You can't see it because you do not "listen" to the "amount" changes. You have to ask :

[self addObserver:self forKeyPath:@"amount" options:NSKeyValueObservingOptionNew context:NULL];"

"So you have to add something in the "observeValueForKeyPath..." function :

else if ([keyPath isEqualToString:@"amount"])
{
    NSLog(@"AMOUNT = %d", self.amount);
    [myQCView [NSNumber numberWithInt:amount] forInputKey:@"inputNumber"];
}"

I tried this, and received two errors: . Unexpected interface name 'NSNumber': expected expression . Parse Issue Expected ']' To match this '['

Is there a simple way to Key-Value bind a slider to an NSNumber ?

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

Try following to get rid of the compile error you want to use either

[myQCView setDefaultValue:[NSNumber numberWithInt:amount] forInputKey:@"inputNumber"];

or

[myQCView setValue:[NSNumber numberWithInt:amount] forKey:@"inputNumber"];

I don't know much about QC but here's how I found your compile error: QCCompositionPickerView Class Reference

mahal tertin
  • 3,239
  • 24
  • 41