views:

198

answers:

1

I have set up an NSCollectionView through Interface Builder. My prototype view contains a progress indicator and a text field. I have set up the bindings so that my "task" object maintains the value of the progress indicator and the text field value.

It all works okay when I add new objects to the collection (via [NSCollectionView newItemForRepresentedObject:] which I add to my array controller). The initial value of the progress indicator and the text field get set appropriately. However, when the values change, it is not reflected in the prototype view. The values always keep their initial value.

I have tried adding a pointer to the prototype view in the "task" object and trying to force an update via [NSView setNeedsDisplay:TRUE] but to no avail. I have subclassed the prototype view and gave it an outlet to the progress indicator so that I could inspect it to see its value at runtime and strangely enough, even though the view is created successfully, the progress indicator is not! Quite contradictory to the fact that it does in fact display and maintain an initial value!

Is there any way I can, using the current setup, propagate the changes to the view?

Thanks in advance.

+2  A: 

Your bindings setup should be sufficient.

What is your progress indicator bound to? Make sure it is sending out KVO notifications when the progress value is updated.

kperryua
The progress bar's value is bound to a value of type double variable. Its also referenced by an outlet defined in the prototype view's subclass.What exactly do you mean by ensuring that it is sending out KVO notifications?
Yip that was it alright, instead of using the setter method - use [self setValue:forKey]! Thanks a lot!
You should mark this answer as correct :-)
Ben Gottlieb
Using the setter method posts KVO notifications automatically unless you explicitly disable that. Most probably, Colin, you assigned directly to the instance variable instead of sending an accessor message.
Peter Hosey