Ios5 iOS 5将NSDictionary转换为NSMutableArray时出现问题?

Ios5 iOS 5将NSDictionary转换为NSMutableArray时出现问题?,ios5,nsmutablearray,nsdictionary,ipod,Ios5,Nsmutablearray,Nsdictionary,Ipod,我正在创建一个IPOD应用程序,我有一个从JSON提要创建的NSDictionary。我正在尝试将其转换为NSMutableArray。我知道我需要在字典中循环,并将键和值写入数组,但代码有问题。这就是实现这一目标的方法 ////从网站获取JSON数据 n错误*错误; NSDictionary*json=[NSJSONSerialization JSONObjectWithData:数据选项:针织错误:&错误] ////// convert the dictionary to an NSMuta

我正在创建一个IPOD应用程序,我有一个从JSON提要创建的NSDictionary。我正在尝试将其转换为NSMutableArray。我知道我需要在字典中循环,并将键和值写入数组,但代码有问题。这就是实现这一目标的方法

////从网站获取JSON数据 n错误*错误; NSDictionary*json=[NSJSONSerialization JSONObjectWithData:数据选项:针织错误:&错误]

////// convert the dictionary to an NSMutableArray
// create an empty array of size equal to the number of json records
NSMutableArray *users = [[NSMutableArray alloc] initWithCapacity:1];                           
//  Begin filling the array
NSInteger dCount = [json count];

for(int i=0; i <  dCount; i++)
{
    User *user = [[User alloc] init];
    user.emailAddress = [json objectForKey: @"emailAddress"];
    user.password = [json objectForKey: @"password"];
    user.password = [json objectForKey: @"password"];
    [users addObject:user];
    NSLog(@"This is record: %@", i);
//将字典转换为NSMutableArray
//创建一个大小等于json记录数的空数组
NSMutableArray*用户=[[NSMutableArray alloc]initWithCapacity:1];
//开始填充数组
NSInteger dCount=[json计数];
对于(int i=0;i
}


提前感谢。

好的可能不是最优雅的解决方案,但在大量帮助下,我想出了以下方法:

////////////////在服务上构建用户阵列 调度队列bgQueue=调度获取全局队列(调度队列优先级默认为0); 调度异步(bgQueue^{

////// Building users list
//Get the data from the webserver 
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://msis-discussion-forum.appspot.com/users"]];

NSLog(@"Beginning to build array");
////   Get the JSON data from the website
NSError* error;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"This is my JSON data %@", json);
usersArray =[[NSMutableArray alloc]init];
NSArray *userJSONObjects = [json objectForKey:@"users"];
for (User *tempUser in userJSONObjects)
{
    User *user = [[User alloc] init];
    user.displayName = [tempUser valueForKey:@"displayName"];
    NSLog(@"%@",user.displayName);
    user.emailAddress = [tempUser valueForKey:@"emailAddress"];
    NSLog(@"%@",user.emailAddress);
    user.password = [tempUser valueForKey: @"password"];
    NSLog(@"%@",user.password);
    [usersArray addObject:user];
} 
 }); 
希望能有帮助