Làm cách nào để truyền một phương thức làm tham số cho phương thức khác? Tôi đang làm điều này trên các lớp học.Phương thức truyền dẫn mục tiêu-C làm tham số
Class A:
+ (void)theBigFunction:(?)func{
// run the func here
}
Class B:
- (void)littleBFunction {
NSLog(@"classB little function");
}
// somewhere else in the class
[ClassA theBigFunction:littleBFunction]
Loại C:
- (void)littleCFunction {
NSLog(@"classC little function");
}
// somewhere else in the class
[ClassA theBigFunction:littleCFunction]
Bạn vượt qua bộ chọn s, Đây là câu hỏi tương tự: http://stackoverflow.com/questions/519600/is-it-possible-to-pass-a-method-as-an-argument-in-objective-c – utahwithak