Two questions:
<SomeProtocol>
in C-function declaration? In function body? (pseudocode)
// myfunc.h
void myfunc(void *object, int param);
// myfunc.c
void myfunc(void *object, int param) {
// desired (pseudocode):
// [<SomeProtocol>(id)object method:param];
}
// objective-c controller
# include "myfunc.h"
// ....
@implementation
- (void)visible_to_outer_world {
Object *o = [Object new];
myfunc(o, 5);
}
// ....
@end
Is it possible to send an Objective-C message to a
void *
from a C function?
Not sure why you would want it, but if you're compiling as Objective-C:
void bar(void *ptr)
{
// MRC version:
[(id)ptr someMessage];
// ARC (alias "ugly") version:
[(__bridge id)ptr someMessage];
}
Foo *foo = [[Foo alloc] init];
bar(foo);
Is it possible to hint
void *
with<SomeProtocol>
in a C function declaration? In a function body?
No.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.