不兼容的指针类型将 'NSString *__strong *' 发送到 'NSError * _Nullable __autoreleasing * _Nullable' 类型的参数

Incompatible pointer types sending 'NSString *__strong *' to parameter of type 'NSError * _Nullable __autoreleasing * _Nullable'

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

这是我的代码:

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

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

行:

NSString *error;

需要:

NSError *error;