2012-08-14 3 views
-3

@selector로 전달되는 메서드에 인수가있는 경우 구문에 도움이 필요합니다. 감사!Objective-C performSelectorOnMainThread의 인수를 사용하여 메시지 전달 :

//This works 
dispatch_async(kBgQueue, ^{ 

[self performSelectorOnMainThread:@selector(hydrateList) withObject:nil waitUntilDone:YES]; 

}); 



//But what about when the method in the selector has arguments? 
//This is incorrect, syntactically 
    dispatch_async(kBgQueue, ^{ 

    [self performSelectorOnMainThread:@selector(hydrateListForCategory:self.categorySelected) withObject:nil waitUntilDone:YES]; 
    }); 
+3

그 방법에 대한 검색 및 문서를 참조하십시오. [NSObject documentation] (https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/nsobject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/performSelectorOnMainThread:withObject : waitUntilDone :) – MechEthan

답변

1
[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES]; 
3

힌트 : 일부가 다음 "withObject는"그 이유는.

힌트 2 : Apple은 프레임 워크에 대해 꽤 좋은 문서를 가지고 있습니다.

힌트 3 :

[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];