On Feb 4, 2009, at 13:10, Ken Thomases wrote:

On Feb 4, 2009, at 2:47 PM, Cem Karan wrote:

I know that we can only modify GUI elements from the main thread, but can we get the values for objects from other than the main thread? E.g., assume I have an editable NSTextField, and I have a worker thread. The user edits the field, clicks a button, and the main thread hands off the analysis to a worker thread. The worker thread then directly queries the NSTextField via its stringValue method. Is this kosher?

No.  First, NSTextField isn't on the list of thread-safe classes.

But quite aside from that, even if it were safe, you could not be sure the value you would get is the value you should get. It might have changed since the task was started.

And quite aside from *that*, in absence of mitigating evidence, it would be an abuse of the MVC design pattern for the analyzing code to ask the user interface for the data model's data.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to