關於performSelector的執行


通過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; //隱含產生新線程。




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章