如何在Obj-C应用程序中访问和使用dylib?
我做了一个包含以下代码的dylib:
Test.h:
#import <Cocoa/Cocoa.h>
@interface Test : NSObject {
int number;
}
-(void)beep;
-(void)giveInt:(int)num;
-(int)takeInt;
@end
Test.m:
#import "Test.h"
@implementation Test
-(void)beep {
NSBeep();
}
-(void)giveInt:(int)num {
number = num;
}
-(int)takeInt {
return number;
}
@end
我编译了dylib并把它放在另一个项目中,但我似乎无法弄清楚如何从dylib创建一个Test对象并调用一些方法。
有人知道怎么做吗?
谢谢,
马特
没有找到相关结果
已邀请:
1 个回复
瞧叮
你想要包含一些错误检查,但这是基本的想法。如果您想使用NSBundle(根据具体情况可能更“合适”),请参阅http://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/AccessingaBundlesContents/AccessingaBundlesContents.html)