Cの関数からObjective-Cのメソッドを呼ぶ方法

2009/10/18 at 07:19 コメントを残す


以下のリンクからパクってきました。
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 ....

非公式コミュニケーションの大事さ 右のEnterキー(英文キーボードの場合altキー)をForward Deleteキーに変更する方法

コメントを残す

Trackback this post  |  Subscribe to the comments via RSS Feed


カレンダー

2009年10月
 1234
567891011
12131415161718
19202122232425
262728293031  

Most Recent Posts