سؤال

I have method A that download images and it start it in background. Then it finished, it runs completion block. I run method A and I in his completion block. I want to know - now I am in main or in background thread?

هل كانت مفيدة؟

المحلول 2

You're probably still in a background thread. As was mentioned you can check if you're in the background using

[NSThread isMainThread]

If you want to switch to the main thread you can use

dispatch_async(dispatch_get_main_queue(), ^{

    // do some things here in the main queue
    // for example: update UI controls, etc.
});

نصائح أخرى

You can use:

[NSThread isMainThread];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top