Search code examples
objective-cpointerstype-conversionincompatibletypeerror

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


I am facing this warning in my project. Welcome to suggestions.. and Thanks :).

This is my code :

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

Solution

  • Look at the documentation for propertyListWithData:options:format:error:. Note the data type for the error parameter. Now look at how you declared your error variable.

    The line:

    NSString *error;
    

    needs to be:

    NSError *error;