I have a string which i get from the response and it 开发者_JAVA百科is like this
@"status=y&message=Not+available&code=110";
Now i want to parse the string and get all the key-value pairs.
OR
Can i get a dictionary with all the key-value pairs from the string above
Thank u in advance
@raaazNSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
for (NSString* queryPart in [yourResponseAsNSString componentsSeparatedByString:@"&"]) {
NSArray* keyValue = [queryPart componentsSeparatedByString:@"="];
[parameters setObject:[keyValue objectAtIndex:1] forKey:[keyValue objectAtIndex:0]];
}
精彩评论