【问题标题】:Receiver 'SMClient' for class message is a forward declaration类消息的接收者“SMClient”是前向声明
【发布时间】:2013-06-04 18:03:35
【问题描述】:

我正在尝试将StackMob 添加到我的项目中。它说在将 SDK 拖到项目后创建一个SMClient 实例,检查“为...创建组”并添加到目标。我关注了这些steps

但是,当我创建 SMClientSMCoreDataStore 实例时,它给了我一个错误 Receiver 'SMClient' for class message is a forward declarationSMCoreDataStore 的错误。这是我的代码:

#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>

@class SMClient;
@class SMCoreDataStore;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (strong, nonatomic) SMCoreDataStore *coreDataStore;
@property (strong, nonatomic) SMClient *client;

@end

还有我的一部分.m

#import "AppDelegate.h"
#import "StackMob.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.client = [[SMClient alloc] initWithAPIVersion:@"0" publicKey:@"YOUR_PUBLIC_KEY"];
    self.coreDataStore = [self.client coreDataStoreWithManagedObjectModel:self.managedObjectModel];

    return YES;
}

我已经清理了项目,导入了相关的头文件,但仍然报错。

有什么想法吗?

【问题讨论】:

    标签: ios objective-c forward-declaration appdelegate


    【解决方案1】:

    这可能是因为您忘记了导入类。 将其添加到您的 .m 中:

    #import "SMClient.h"
    #import "SMCoreDataStore.h"
    

    【讨论】:

    • 修复它!但这很奇怪,因为StackMob.h 导入了这两个类,尽管如果我只导入那个头文件,它会给我那个错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 2012-11-07
    相关资源
    最近更新 更多