iOS Are methods called by delegates and observers executed on the main thread?

后端 未结 3 642
别跟我提以往
别跟我提以往 2020-12-11 00:59

Sorry, I\'m not sure of the right language here, but when methods are called because they are either delegate methods, or methods called as a result of being listed as the t

3条回答
  •  渐次进展
    2020-12-11 01:34

    As stated, the thread will vary based on the caller. In your delegate method, if you need to adapt, you can always do something like this:

    if ([NSThread isMainThread]) {
        // do the UI stuff as normal
    } else {
        dispatch_async(dispatch_get_main_queue(), ^{ UI stuff });
    }
    

提交回复
热议问题