开发者

Decode HTML response in Objective-C

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

@raaaz


NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
for (NSString* queryPart in [yourResponseAsNSString componentsSeparatedByString:@"&"]) {
  NSArray* keyValue = [queryPart componentsSeparatedByString:@"="];
  [parameters setObject:[keyValue objectAtIndex:1] forKey:[keyValue objectAtIndex:0]];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜