通過NSObject的Category方法調用,羅列如下:
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait; //在主線程中運行方法,wait表示是否阻塞這個方法的調用,如果爲YES則等待主線程中運行方法結束。一般可用於在子線程中調用UI方法。
- (void)performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait; //在指定線程中執行,但該線程必須具備run loop。
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg; //隱含產生新線程。