开发者

Function pointer in iOS?

开发者 https://www.devze.com 2023-01-13 02:35 出处:网络
Anybody can tell me about Function pointer in 开发者_运维百科iOS? Thanks :DIf I understand properly what you are thinking of.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号