2011-04-09 88 views
1

我有以下代码的每个项目:显示从一个NSArray

for (int i = 1; i <= count; i++) { 

    NSString *j = [[NSString alloc] initWithFormat:@"%d", i]; 

    NSArray *fields = [[NSArray alloc] initWithObjects: 
         @"name", nil]; 
    //@"title",@"mobile",@"email",@"website" 
     [requestExecute setMethod:@"execute" withObjects:[NSArray arrayWithObjects: 
                 @"testdb", userid, @"admin", @"res.partner.contact", @"read", j, fields, nil]]; 
    NSDictionary *records = [self executeXMLRPCRequest:requestExecute]; 

    NSLog(@"\nKey : %@ value : \n", records); 
} 

输出类似于

2011-04-09 12:34:32.431 Erp[1571:207] ( 
     { 
     email = "[email protected]"; 
     id = 1; 
     mobile = 12345; 
     name = Mortier; 
     title = "Ms."; 
     website = "www.benoit.com"; 
    } 
) 
2011-04-09 12:34:32.515 Erp[1571:207] ( 
     { 
     email = "[email protected]"; 
     id = 2; 
     mobile = 23455; 
     name = Jacot; 
     title = "M."; 
     website = "www.laurent.com"; 
    } 
) 
2011-04-09 12:34:32.599 Erp[1571:207] ( 
     { 
     email = "[email protected]"; 
     id = 3; 
     mobile = 34567; 
     name = Passot; 
     title = "M."; 
     website = "www.thomas.com"; 
    } 
) 
2011-04-09 12:34:32.683 Erp[1571:207] ( 
     { 
     email = "[email protected]"; 
     id = 4; 
     mobile = 45678; 
     name = Lacarte; 
     title = Mss; 
     website = "www.etienne.com"; 
    } 
) 
2011-04-09 12:34:32.767 Erp[1571:207] ( 
     { 
     email = "[email protected]"; 
     id = 5; 
     mobile = 56789; 
     name = Tang; 
     title = Mss; 
     website = "www.chow.com"; 
    } 
) 
2011-04-09 12:34:32.851 Erp[1571:207] ( 
     { 
     email = "[email protected]"; 
     id = 6; 
     mobile = 1237091; 
     name = Wong; 
     title = "M."; 
     website = "www.hudson.com"; 
    } 
) 

这将打印的每个记录一个接一个。现在我想逐一记录这个记录中的每个字段。任何帮助,将不胜感激。

回答

2

你可以尝试循环使用这一个每个键:

for(NSString *key in records) { 
    //do something with key or [records objectForKey:key]; 
}