Re: Problem with binding of @count
Re: Problem with binding of @count
- Subject: Re: Problem with binding of @count
- From: j o a r <email@hidden>
- Date: Fri, 28 Nov 2008 14:49:49 -0800
On Nov 28, 2008, at 11:41 PM, Mikael Wämundson wrote:
-(NSString *) numberOfStudents
{
return [NSString stringWithFormat:@"The number of students is: %@",
[theStudentArrayController
valueForKeyPath:@"arrangedObjects.@count"]];
}
I think that it would be more straight forward and efficient to write
that:
[NSString stringWithFormat:@"The number of students is: %lu",
((unsigned long)[theStudentArrayController count])];
No error during compilation or run-time, but value in the text label
is not updated when the array is changed.
That's because you haven't told the bindings machinery that the
"numberOfStudents" property depends on the count of objects in the
array. See:
<http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/DependentKeys.html
>
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden