Re: Bindings
Re: Bindings
- Subject: Re: Bindings
- From: Sandro Noel <email@hidden>
- Date: Sat, 26 May 2007 23:17:09 -0400
so let me see if i'm thinking this correctly .
I have a class instance in interface builder "MyController" with an
outlet called "_servicesList" wich is of type NSMutableArray
and i also have the serviceList accessor that returns.
( because i was trying both the outlet and the accessor )
in that class "MyController" on init I instanciate a class that
collect's services and generates an Array of NSServices
with an accessor method that gives me that array.
i then assign it to my Outlet "_servicesList" from interface builder.
in interface builder
i have a NSObjectController connected to "MyController" on "content"
then in interface bujilder i have an NSArrayController bound to
NSObjectController on the key servicesList
then i have my TableView's column bound to the NSArrayControler, on
the key name.
and the class is set to NSNetService.
am i geting this right ?
Sandro Noel
email@hidden
On 26-May-07, at 10:53 PM, I. Savant wrote:
Well, in all fairness, maybe I wasn't being clear (or rather,
precise).
If you have an object (say, a document) and it has an array
called _bServices with a controller bound to it via, say
"bServicesArrayAccessor", any changes you make directly to that
array (adding/removing) need to be enclosed in the appropriate
notifications:
[self willChangeValueForKey:@"bServicesArrayAccessor"];
[_bServices addObject:someObject];
[self didChangeValueForKey:@"bServicesArrayAccessor"];
This will cause anything bound to your document via the
bServicesArrayAccessor key to note the changes (in this case your
controller).
Alternatively you could simply tell your array controller to -
addObject:someObject which would let the array controller to handle
all the notifications, etc. for you. Either way will do.
--
I.S.
On May 26, 2007, at 10:47 PM, Sandro Noel wrote:
OH!!! .... i get it ... :) Sorry for making you repeat ... i'll
try it :)
Sandro Noel
email@hidden
On 26-May-07, at 10:46 PM, I. Savant wrote:
_bServices is a NSMutableArray Object.
i'm adding the NSNet Services to it.
Okay, then ...
you're "changing the array behind the controller's back".
So ...
a) Call -willChangeValueForKey: and -didChangeValueForKey:
before/after changing the array, or,
b) Call -addObject: against your array controller.
:-)
If you're changing things behind your controller's back (which
handles KVO notifications for you), then it's up to you to
properly notify (-will/didChangeValueForKey:).
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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