开发者

Decode HTML response in Objective-C

开发者 https://www.devze.com 2023-02-16 18:51 出处:网络
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.

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

精彩评论

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