objective c爆炸NSString

时间:2012-12-14 08:41:19

标签: iphone objective-c

我在目标c中需要与此相当的东西

list($var1,$var2) = explode("=",$array);

我试过

NSArray *stringArray = [postString componentsSeparatedByString:@"&"];
for (NSString* str in stringArray) {
     NSArray *keyvalue = [str componentsSeparatedByString:@"="];
     [postParam setValue:[keyvalue objectAtIndex:1] forKey:[keyvalue objectAtIndex:0]];
     [postData addObject:postParam];
}

但我的应用程序崩溃了

  

< __ NSDictionaryI 0x727abc0> setValue:forUndefinedKey:]:这个类是   对于关键XY

,不符合关键值编码

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

[postParam setValue:[keyvalue objectAtIndex:1] forKey:[NSString stringWithFormat:@"%@",[keyvalue objectAtIndex:0]]];