用于类消息的接收者'SMClient'是前向声明

时间:2013-06-04 18:03:35

标签: ios objective-c forward-declaration appdelegate

我正在尝试将StackMob添加到我的项目中。它表示在将SDK拖动到项目后创建SMClient实例,选中“为...创建组”并添加到目标。我遵循了这些steps

但是,当我创建SMClientSMCoreDataStore个实例时,它会给我Receiver 'SMClient' for class message is a forward declaration的错误,SMCoreDataStore的错误也相同。这是我的代码:

#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;
}

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

有什么想法吗?

1 个答案:

答案 0 :(得分:7)

这可能会发生,因为您忘记导入类。 将它添加到.m:

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