Re: Bindings
Re: Bindings
- Subject: Re: Bindings
- From: Sandro Noel <email@hidden>
- Date: Sat, 26 May 2007 22:26:37 -0400
Chris, thank you for your pointer ... but i did make sure the class
was compliant :).
In any case thank you for pointing it out, i might-a-had forgotten to
check :)
here is a piece of code.
In order for a class to be considered KVC compliant for a specific
property, it must implement the methods required for valueForKey: and
setValue:forKey: to work for that property.
NSNetService does have these methods.
for example ...
- (void)netServiceBrowser:(NSNetServiceBrowser *)browser
didFindService:(NSNetService *)aNetService
moreComing:(BOOL)moreComing
{
NSLog([aNetService valueForKey:@"name"]);
// add the Object to the list.
[_bServices addObject:aNetService];
if(!moreComing)
{
NSLog([NSString stringWithFormat:@"%d",[_bServices count]]);
[_mbrowser stop];
}
}
oupputs:
_workstation
_afpovertcp
_net-assistant
_rfb
_airport
_smb
_adisk
_nssocketport
Sandro Noel
email@hidden
On 26-May-07, at 10:07 PM, Chris Hanson wrote:
On May 26, 2007, at 6:20 PM, Sandro Noel wrote:
ok here is my case.
I have a NSMutableArray of NSNetService
Stop right here. Do you know whether NSNetService supports Key-
Value Observing? This is a requirement for anything you wish to
bind to.
As someone put it not too long ago on the list (diagram reproduced
from memory):
Change in model object uses KVO to propagate through controller
objects to view objects:
Model o----[KVO]--->> Controller o----[KVO]--->> View
Manipulation of view uses KVC to push changes through controller
object to model object:
Model <----[KVC]----o Controller <----[KVC]----o View
When a model object changes, it posts KVO notifications. If a view
is bound to a model object (via a controller, of course) it will
get them via the controller. When a user manipulates a view
object, the view object uses key-value coding to push those changes
through its controllers to the appropriate model object.
This means that anything used in bindings will have to be KVC and
KVO compliant.
Another important question: Do you consider NSNetService instances
to be model objects in your application? For the vast majority of
applications -- even in the case of something like Xcode's
Distributed Build preferences -- the answer is likely to be "No."
I think you would probably be better off creating your own model
class that supports Key-Value Observing, and which represent the
actual model of your application. Then instances of this class can
either *use* NSNetService instances or be *managed by* something
that uses NSNetService instances to locate services via Bonjour.
-- Chris
_______________________________________________
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
References: | |
| >Bindings (From: Sandro Noel <email@hidden>) |
| >Re: Bindings (From: Chris Hanson <email@hidden>) |