Swift & Cocoa: Let an object live in a thread

Viewed 25

I have a class that has many methods that have to do work in the background (async DispatchQueue). It got quite complex to switch between background and main threads (many UI updates)

I'm wondering if it would be a reasonable idea to create the object in a background thread and let it live there. Any change that will cause an UI update could be done in the main thread.

Like:

var objectArray: [MyClass] = []
DispatchQueue.async {
  objectArray.append(MyClass())
}
0 Answers
Related