如何解决发送给类的无法识别的选择器?

Oli*_*lie 3 iphone static-libraries

我的问题类似于这个问题,但主要区别在于我正在使用类方法.一些代码:

OpenFeint的+ private.h

@interface OpenFeint (Private)
// ...
+ (void) createSharedInstance;
Run Code Online (Sandbox Code Playgroud)

OpenFeint的+ private.mm

+ (void) createSharedInstance
{
   //...
}
Run Code Online (Sandbox Code Playgroud)

OpenFeint.mm

+ (void) initializeWithProductKey:(NSString*)productKey 
       andSecret:(NSString*)productSecret 
       andDisplayName:(NSString*)displayName
       andSettings:(NSDictionary*)settings 
       andDelegates:(OFDelegatesContainer*)delegatesContainer
{
    [OpenFeint createSharedInstance];
    // ...
Run Code Online (Sandbox Code Playgroud)

MyApp.mm:

// ...
#import "OpenFeint.h"
// ...
[OpenFeint initializeWithProductKey: OF_PRODUCT_KEY 
        andSecret: OF_PRODUCT_SECRET
        andDisplayName: OF_DISPLAY_NAME
        andSettings: openFeintSettings
        andDelegates: [OFDelegatesContainer containerWithOpenFeintDelegate: self]];
Run Code Online (Sandbox Code Playgroud)

错误是:

2010-07-22 11:30:15.239 MyApp[20210:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[OpenFeint createSharedInstance]: unrecognized selector sent to class 0x1cdb1c'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x02d6f919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x02ebd5de objc_exception_throw + 47
    2   CoreFoundation                      0x02d714eb +[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x02ce1116 ___forwarding___ + 966
    4   CoreFoundation                      0x02ce0cd2 _CF_forwarding_prep_0 + 50
    5   MyApp                               0x0002844d +[OpenFeint initializeWithProductKey:andSecret:andDisplayName:andSettings:andDelegates:] + 48
        // ...
Run Code Online (Sandbox Code Playgroud)

一切都编译和链接就好了,但我得到了这个愚蠢的错误.

最后一件事 - 所有OpenFeint的东西都是静态库,是的,它也是编译和链接的.这是我的第一个静态库,所以我可能只是错过了一些重要的步骤.有线索吗?

谢谢!

Oli*_*lie 7

嗯,我似乎找到了一个解决方法,但我不确定它是否是正确的解决方法.我添加了链接器标志-all_load(除-ObjC之外),现在一切似乎都有效.

问题修订/补充:这是一个"合法"修复吗?还有更好的吗?