On Nov 4, 2008, at 2:22 PM, Jerry Krinock wrote:

I have a class which programatically creates and manipulates an alert window, like NSAlert except it's capable of much more. It exposes about 55 methods, doing stuff like like -setTitle:, - setButtonTitle:, -setProgressAmount:, -removeAllSubviews, - setPopupTitles:, setIconStyle: etc., etc.

Now that I'm learning the coolness of NSOperation, I'd like to be able to invoke these methods from any thread (any NSOperation).

I'd actually caution you against this. Keep your processing distinct from your user interface, don't mix the two. Use some form of intermediate "status" object to pass information back to your main thread for presentation to the user, rather than trying to interact with the user from multiple threads at once.

Otherwise you'll wind up doing one of two things:

(1) Serializing everything as a side effect of attempting to keep interaction with the user safe; or,

(2) Dealing regularly with hard-to-address bugs that are ultimately due to multiple threads interacting with the same data without correct locking.

By keeping the logic that operates on your data distinct from your user interface, you can much more easily scale your logic along with the user's hardware, and keep debugging of both your UI and logic straightforward.

  -- Chris

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to