• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Manual KVO and will/didChangeValueForKey
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Manual KVO and will/didChangeValueForKey


  • Subject: Re: Manual KVO and will/didChangeValueForKey
  • From: Andrew White <email@hidden>
  • Date: Fri, 10 Jun 2005 14:46:09 +1000


Let me give another specific example (10.3.9):

I have an object that manages an NSNetServiceBrowser. It responds to netServiceBrowser:didFindService:moreComing messages but updating a dictionary, indexed by name.

I have an accessor to the dictionary:

- (NSArray *) thingsFound
{
	return [_dict allValues];
}


When I first receive a netServiceBrowser:didFindService:moreComing message I signal [self willChangeValueForKey: @"thingsFound"]. When moreComing goes 'no' I signal [self didChangeValueForKey: @"thingsFound"].


Since the array returned by thingsFound is not sorted, it doesn't really make sense to use array KVO. The entire array has a particular set of values, then something changes and it has a new set of values. Indices are not preserved.


Now consider that I have a controller class with a member _browserManager and a method
- (NSArray *) thingsFound
{
return [_browserManager thingsFound];
}


Obviously, I want the KVO for thingsFound in the controller to mimic those in the browser manager, but I can't figure out the syntax to allow setKeys:triggerChangeNotificationsForDependentKey: to act on another object. How do I indicate that thingsFound in my controller is to mimic thingsFound in my BrowserManager?

Thanks


-- Andrew White

--------------------------------------------------------------------------
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Manual KVO and will/didChangeValueForKey (From: Andrew White <email@hidden>)
 >Re: Manual KVO and will/didChangeValueForKey (From: Tim Lucas <email@hidden>)
 >Re: Manual KVO and will/didChangeValueForKey (From: mmalcolm crawford <email@hidden>)
 >Re: Manual KVO and will/didChangeValueForKey (From: Andrew White <email@hidden>)
 >Re: Manual KVO and will/didChangeValueForKey (From: mmalcolm crawford <email@hidden>)
 >Re: Manual KVO and will/didChangeValueForKey (From: Andrew White <email@hidden>)
 >Re: Manual KVO and will/didChangeValueForKey (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Universal Binaries, x86 and compatibility...
  • Next by Date: Best approach: moving a pointer-like image over an NSImageView
  • Previous by thread: Re: Manual KVO and will/didChangeValueForKey
  • Next by thread: Re: Manual KVO and will/didChangeValueForKey
  • Index(es):
    • Date
    • Thread