I am very new to Xcode and Objective-C, so I don’t really know what I am doing yet! 😉
Basically I want to have an IPhone Application that can run possibly two threads, which will later use UDP Sockets to communicate with other Apps.
I have put functions to react when the start-Thread/stop-Thread Button in the UI are pressed, now I want to fill them with code to actually create and start the threads.
-
What would be the correct procedure here?
-
Do I need to subclass
NSThread? -
Where do I implement the code, that the new threads will execute?
I can’t see a run method, or something similar. I suppose that has something to do with the
selector, which I don’t understand.
Use dispatch queues. They’re essentially lightweight threads for which you don’t need to worry about the threading or queueing directly.
You can use one of the built-in queues or your own.
And you should probably read up on blocks too, in particular the memory management aspect.