NSPropertyListSerialization propertyListWithData produces incompatible conversion warning/error

雨燕双飞 提交于 2019-12-05 12:29:22

When you're trying to read data using NSPropertyListSerialization, you don't specify a format: You either pass in NULL, or pass the memory address of a variable.

NSError *error;    
NSData * tempData = [[NSData alloc] initWithContentsOfFile:@"Data.plist"];
NSPropertyListFormat plistFormat;
NSDictionary *temp = [NSPropertyListSerialization propertyListWithData:tempData options:NSPropertyListImmutable format:&plistFormat error:&error];

The ampersand means "the address in memory where this variable is stored" – by using it, you're giving the method the ability to write to that memory location, and replace the original content of the variable. Both plistFormat and (potentially) error will contain something new after this method is called: plistFormat will tell you what format the plist was in, as opposed to the other way around, and error (which should be of class NSError) will tell you about any errors that were encountered.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!