Function pointer in iOS?
Anybody can tell me about Function pointer in 开发者_运维百科iOS? Thanks :D
If I understand properly what you are thinking of.
1. Like in C
void yourfunc() {}
foo(&yourfunc);
2. In Objective-C You can "refer" to a method using @selector and method sig
- (void) test:(NSInteger)n withTest:(BOOL)isTrue {}
[object performSelector:@selector(test:withTest:)];
If you are asking about the Objective C programming environment of iOS, Objective C is a pure superset of plain ANSI C. So function pointers work exactly the same as in C, and you can use them that same way in your iOS Objective C code.
Pointers to methods (selectors) are something somewhat different though.
精彩评论