views:

27

answers:

1

hi, 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 = [[NSMutableArray alloc] initWithContentsOfURL:url];

+1  A: 

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.

KennyTM
thanx, i used NSPropertyListSerialization.
tester