한 메서드를 다른 메서드에 매개 변수로 전달하는 방법은 무엇입니까? 나는이 수업을 통해 이러고있다.매개 변수로 Objective-C 전달 메서드
클래스 A :
+ (void)theBigFunction:(?)func{
// run the func here
}
는 클래스 B :
- (void)littleBFunction {
NSLog(@"classB little function");
}
// somewhere else in the class
[ClassA theBigFunction:littleBFunction]
는 클래스 C :
- (void)littleCFunction {
NSLog(@"classC little function");
}
// somewhere else in the class
[ClassA theBigFunction:littleCFunction]
당신은 셀렉터 님, 비슷한 질문이 있습니다. http://stackoverflow.com/questions/519600/is-it-possible-to-pass-a-method-as-an-argument-in-objective-c – utahwithak