我是这样读的……
NSString *fileContent = [[NSString alloc] initWithContentsOfFile:path];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *data = (NSDictionary *) [parser objectWithString:fileContent error:nil];
// getting the data from inside of "menu"
NSString *message = (NSString *) [data objectForKey:@"message"];
NSString *name = (NSString *) [data objectForKey:@"name"];
NSArray *messagearray = [data objectForKey:@"message"];
NSArray *namearray = [data objectForKey:@"name"];
NSDictionary* Dictionary = [NSDictionary dictionaryWithObjects:message forKeys:name];
for (NSString* Key in [Dictionary allKeys]){
NSLog(@"%@ %@",Key,[Dictionary objectForKey:Key]);
}
...这个 JSON 文件...
{"message":["Untitled1a","Untitled2a","Untitled3a"],"name": ["Untitled1b","Untitled2b","Untitled3b"]}
……这就是结果……
Untitled3b Untitled3a
2012-05-12 11:31:17.983 Quick Homework[721:f803] Untitled1b Untitled1a
2012-05-12 11:31:17.983 Quick Homework[721:f803] Untitled2b Untitled2a
...但是对于每一对(无标题 1b 2b),我想分配两个 UITextField,以显示对应的文本...
我尝试使用这种方法:
for (NSString *string in messagearray){
}do{
NSLog(@"happt = %i", b);
b++;
}
while(b == b);
//While loop
while (b == b ) {
NSLog(@"x = %i", b);
b++;
}
}
我想计算数组中的对象,以便重复 UITextField 的分配代码该次数,并相应地显示文本,但我不能。请帮忙!!