i have an NSString that is value in plist format. i download this string from url. but i dont wanna write it to a file. when the string comes Asynchronous, i want to put it to nsmutablearray. how can i convert string (in plist format) to nsmutablearray? there is some methods, initWithContentsOfURL, initWithContentsOfFile. but no intiwithstring.
this method works Synchronous: NSMutableArray *tmpArray = [[NSMutable开发者_开发知识库Array alloc] initWithContentsOfURL:url];
There is a -propertyList
method in NSString.
NSMutableArray* tmpArray = [[theString propertyList] mutableCopy];
...
[tmpArray release];
Note that this method will throw an exception (i.e. throw) if the string is not in plist format. To have a better error checking, try to download the data as NSData, and use the NSPropertyListSerialization methods.
精彩评论