Reputation: 318
i want to write NSString into NSMutableArray.Please look at the following code:
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
returnString = [returnString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(returnString);
Here i get some response(a plist file) from a server which i saved as NSData and then convert it to NSString.When i print this NSString it looks like following.
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>sourav sas</string>
<string>dipto pol</string>
<string>Shahriar Alam</string>
<string>toukir naim</string>
<string>shamim mohiuddin</string>
</array>
</plist>
Now i want to copy this NSString into an NSMutableArray.Each index of NSMutable array will contain the names between tag. How can i do that.
Upvotes: 2
Views: 212
Reputation: 6082
NSMutableArray *array = [NSPropertyListSerialization propertyListFromData:data
mutabilityOption:NSPropertyListMutableContainers
format:NULL
errorDescription:NULL];
Upvotes: 2
Reputation: 3579
You need to use NSXMLParser. See this tutorial:
http://codesofa.com/blog/archive/2008/07/23/make-nsxmlparser-your-friend.html
Upvotes: 2