我有从sqlite
检索的字符串({
studentId = SUE1291ST;
studentName = "Student123Sdfw";
},
{
studentId = SUE13291ST;
studentName = "name123Sdfw";
})
如何转换为NSMutableArray
并获取NSDictionary
....?
答案 0 :(得分:0)
如果格式为json(正如您的代码所示),最简单的方法是使用NSJSONSerialization
使用
+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error
会给你一个返回的基础类对象(NSArray,NSDictionary,取决于json数据)
答案 1 :(得分:0)
u want dict values from array..so
dataArray =[NSMutableArray array];
NSMutableDictionary *dic =[[NSMutableDictionary alloc]init];
[dic setObject:@"SUE1291ST" forKey:@"studentId"];
[dic setObject:@"Student123Sdfw" forKey:@"studentName"];
[dataArray addObject:dic];
dic =[[NSMutableDictionary alloc]init];
[dic setObject:@"SUE13291ST" forKey:@"studentId"];
[dic setObject:@"name123Sdfw" forKey:@"studentName"];
[dataArray addObject:dic];
NSLog(@"dataArray:%@",dataArray);
for (NSDictionary *dic in dataArray) {
NSLog(@"DICTIONARY IS:%@",dic);
}