Cの関数からObjective-Cのメソッドを呼ぶ方法
以下のリンクからパクってきました。
http://stackoverflow.com/questions/304885/unable-to-call-an-objective-c-method-from-a-c-function
#import <Cocoa/Cocoa.h>
id refToSelf;
@interface SomeClass: NSObject
@end
@implementation SomeClass
- (void) doNothing
{
NSLog(@"Doing nothing");
}
@end
int otherCfunction()
{
[refToSelf doNothing];
}
int main()
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
SomeClass * t = [[SomeClass alloc] init];
refToSelf = t;
otherCfunction();
[pool release];
}
Entry filed under: Objective-C is ....
Trackback this post | Subscribe to the comments via RSS Feed