【问题标题】:ios incompatible pointer types assigning to NSError _strong from NSError _autoreleasingios 不兼容的指针类型从 NSError _autoreleasing 分配给 NSError _strong
【发布时间】:2013-06-24 17:54:29
【问题描述】:

我收到此错误:

incompatible pointer types assigning to NSError _strong from NSError _autoreleasing

这是我的头文件:

@interface myClass : NSObject

{
    NSError *errorPointer;
}

这是我的实现文件:

- (id)initWithError:(NSError **)error
{
    if (self = [super init])
    {
        errorPointer = error; // <-- here is where I'm getting the error
    }
    return self;
}

你们中的任何人都知道为什么或如何解决此错误吗?

非常感谢您的帮助。

【问题讨论】:

    标签: objective-c nserror


    【解决方案1】:

    (NSError **)error 应该是 (NSError *)error

    【讨论】:

    • 你能详细说明为什么会这样,或者什么时候会这样,因为我能找到的每个例子都说要使用 (NSError **)
    • @LogicsaurusRex NSError** 用于从函数返回(通常是可选的)值。如果 NSError 是一个普通的传入对象(罕见但可能),则使用 NSError*。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    • 2018-11-17
    • 2014-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多