2011-03-15 41 views
1

我有一個字符串,我從響應中得到,它是這樣的在Objective-C中解碼HTML響應

@"status=y&message=Not+available&code=110";
現在我想解析字符串並獲取所有的鍵值對。
OR
我可以得到從字符串中的所有鍵值對的字典上面
感謝ü提前
@raaaz

回答

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

呀它的工作原理。十分感謝... – SNR 2011-03-15 13:01:41