• 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: Key-Value Binding and Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key-Value Binding and Threads


  • Subject: Re: Key-Value Binding and Threads
  • From: Chris Kane <email@hidden>
  • Date: Fri, 30 Mar 2007 09:18:49 -0700

On Mar 26, 2007, at 9:10 PM, King Chung Huang wrote:

Before everyone groans: No, I'm not asking if KVB is "thread-safe".

Searching on CocoaBuilder, the consensus seems to be that KVB is not "thread-safe" in terms of mutating a key on a thread other than the main thread and expecting UI changes to occur correctly. Would I be correct in deducing that KVO/KVB change notifications are processed on the thread where willChangeValueForKey: etc. is implicitly or explicitly called? i.e., if I mutate an observed value on thread B, then observers will be notified on thread B? Can I safely observe a key on object A from object B, if both objects are safe to mutate on the same thread?


I believe it is safe to say that the KVO notification will be delivered on the thread on which the mutation (and will/ didChangeValueForKey: around it) occurs. The KVO notifications are simply immediately delivered, synchronously. Same as with NSNotifications.

This assumption would break if we ever changed things to automatically shunt the KVO notification delivery to another thread (say, the main thread). But I don't think we should ever do that, and instead leave it to the developer to do that if they need to. Or, do that up at higher levels, not at the low KVO level.


Chris Kane Cocoa Frameworks, Apple

_______________________________________________

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: 
 >Key-Value Binding and Threads (From: King Chung Huang <email@hidden>)

  • Prev by Date: Re: Converting WebView to JPEG
  • Next by Date: Re: Converting WebView to JPEG
  • Previous by thread: Key-Value Binding and Threads
  • Next by thread: NSHTTPCookieManagerCookiesChangedNotification ?
  • Index(es):
    • Date
    • Thread