简体   繁体   English

接收方类型是前向声明

[英]Receiver type is forward declaration

I have this code (along with other stuff): 我有这个代码(以及其他东西):

- (NSManagedObjectContext *) managedObjectContext
{
    assert([NSThread isMainThread]);
    if (_managedObjectContext != nil) {
        return _managedObjectContext;
    }
    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
    if (coordinator != nil) {
        _managedObjectContext = [[NSManagedObjectContext alloc] init];
        [_managedObjectContext setPersistentStoreCoordinator: coordinator];
    }

    return _managedObjectContext;
}

These lines are giving me errors that class message is a forward declaration: 这些行给了我错误,类消息是一个前向声明:

_managedObjectContext = [[NSManagedObjectContext alloc] init];
[_managedObjectContext setPersistentStoreCoordinator: coordinator];

What is this and how do I fix it? 这是什么,我该如何解决?

You must import CoreData/CoreData.h in the file Supporting Files/YourApp-Prefix.pch: 您必须在Supporting Files / YourApp-Prefix.pch文件中导入CoreData / CoreData.h:

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <CoreData/CoreData.h>
#endif

By forward Declaration means you must be declaring class by @Class . 通过前向声明意味着您必须通过@Class声明类。 Import the Class in the .h/.m file and hope so it will resolve the issue. 导入.h / .m文件中的类,希望它能解决问题。

将其添加到.h或.m文件的顶部

#import <CoreData/CoreData.h>

我通过在使用Swift类的Objective C类中导入#import“Project-Name-Swift.h”文件解决了这个问题。

I Change file DDXML.h and Work. 我更改文件DDXML.h和工作。

File: DDXML.h 文件:DDXML.h

Change: 更改:

#if TARGET_OS_IPHONE && 0 // Disabled by default

To: 至:

#if TARGET_OS_IPHONE && 1 // Disabled by default

这在我重命名一个类后经常发生,然后忘记在头文件中更新@class myclass(显然不会抛出编译错误。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类消息的接收器类型“WkAlertAction”是前向声明 - Receiver type "WkAlertAction" for class message is a forward declaration 实例消息的接收者类型“ xxx”是前向声明 - Receiver type 'xxx' for instance message is a forward declaration &#39;接收器类型“CCParticleBatchNode”用于类消息是前向声明&#39; - 'Receiver type “CCParticleBatchNode” for class message is a forward declaration' "接收者类型 *** 例如消息是前向声明" - receiver type *** for instance message is a forward declaration 实例消息的接收者类型“ X”是前向声明CGPOINT,IOS - Receiver type ‘X’ for instance message is a forward declaration CGPOINT, IOS 实例消息的接收方类型()是ARC中的前向声明问题 - Receiver type () for instance message is a forward declaration issue in ARC xcode 4.6中的“Receiver type for instance messages是一个前向声明” - “Receiver type for instance messages is a forward declaration” in xcode 4.6 构建时间错误:例如,消息的接收者类型*是前向声明 - Build Time Error: Receiver type * for for instance message is a forward declaration 这里的“实例消息的接收者类型&#39;CALayer&#39;是转发声明”是什么意思? - What does “Receiver type 'CALayer' for instance message is a forward declaration” mean here? 类消息的接收方“ SMClient”是前向声明 - Receiver 'SMClient' for class message is a forward declaration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM