Manisha Manisha - 7 months ago 14
iOS Question

how to start a global thread in swift

Is there any way to start and stop a thread in swift along with it making the thread global also so that it can used anywhere.

As shown below, this is how i create thread in swift

var objThrd = SimpleClass()
let thread = NSThread(target: objThrd , selector: "createSimpleObj", object: nil)

Please give an example if feasible. Or can we achieve this via NSOperation ?

Max Max

Use Grand Central Dispatch

    let myQueue: dispatch_queue_t = dispatch_queue_create("com.example.queue", nil)
    dispatch_async(myQueue, { () -> Void in
        // Execute some code