2012-05-16 22 views
0

我正在尝试构建一个使用Growl的基本可可应用程序。有没有办法使用GrowlApplicationBridge没有NSClassFromString?

每次我想用GrowlApplicationBridge我有使用类似

Class GAB = NSClassFromString(@"GrowlApplicationBridge"); 
[GAB performSelector:@selector(setGrowlDelegate:) withObject:self]; 

我希望能够只使用

[GrowlApplicationBridge setGrowlDelegate:self]; 

这里的编译器错误,我得到的,当我尝试我想要的行为:

Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_GrowlApplicationBridge", referenced from: objc-class-ref in StatusMenuAppDelegate.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

回答

2

只要您导入<Growl/Growl.h>在该文件的顶部并将框架链接到您的应用程序中,您应该可以使用[GrowlApplicationBridge setGrowlDelegate:self]就好了。

检查文件的顶部并确保导入它,然后检查目标的“链接库和框架”构建阶段并确保链接它。

+0

谢谢:)我在复制框架而不是链接它。 – Cyrus

+0

@Cyrus:你需要做这两件事。如果你不复制它,你的应用程序将无法启动,因为你的用户不会拥有它。如果你没有链接它,复制它是没有用的。您必须复制它(以便它会出现在用户的机器上)并链接到它(以便您的应用程序将实际使用它)。 –

+0

明白了。谢谢你的帮助。 – Cyrus