0
votes

Question for ObjectiveC gurus w/ some WinAPI background:

Is there support for COM-like apartment threading model in ObjectiveC?

  • Class A is single-threaded: all objects of class A are created in one specific thread, and all message handlers are invoked in that thread
  • Class B is multi-threaded: objects of class B can be created in any caller thread, and all message handlers are invoked only in original thread used to create the object
  • Class C is free-threaded: objects of class C can be created in any caller thread, message handlers can be invoked in any thread

My thoughts are: since ObjectiveC is about messages, COM+ like multi-threading can be easily achieved. Or not?

Thank You

1

1 Answers

1
votes

There is no built-in support for single-threaded or multi-threaded objects as defined by your question.

In Mac OS X or iOS apps, you'd probably want to use GCD queues to enforce these policies yourself. I recommend the WWDC 2011 videos named “Blocks and Grand Central Dispatch in Practice” and “Mastering Grand Central Dispatch” for some great advice on applying GCD.