【问题标题】:Incompatible pointer types sending 'NSString *__strong *' to parameter of type 'NSError * _Nullable __autoreleasing * _Nullable'不兼容的指针类型将“NSString *__strong *”发送到“NSError * _Nullable __autoreleasing * _Nullable”类型的参数
【发布时间】:2018-05-28 05:15:56
【问题描述】:

我在我的项目中面临这个警告。欢迎提出建议......谢谢:)。

这是我的代码:

NSString *profile = @"Profile";
NSData *data = [profile dataUsingEncoding:NSUTF8StringEncoding];
NSString *error;
NSPropertyListFormat format;
NSDictionary *dict = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&format error:&error];

【问题讨论】:

    标签: objective-c pointers type-conversion incompatibletypeerror


    【解决方案1】:

    查看propertyListWithData:options:format:error: 的文档。注意error 参数的数据类型。现在看看你是如何声明 error 变量的。

    行:

    NSString *error;
    

    需要:

    NSError *error;
    

    【讨论】:

    • 警告消失了。谢谢rmaddy
    • 很高兴为您提供帮助。请不要忘记接受可以解决您问题的答案。
    • 当然我接受了.. 新的堆栈溢出.. 谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多