I am reading like this…
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]);
}
…this JSON file…
{"message":["Untitled1a","Untitled2a","Untitled3a"],"name": ["Untitled1b","Untitled2b","Untitled3b"]}
…this is the result…
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
…but for each pair (Untitled 1b 2b) I would like to alloc two UITextFields, witch display the correspondent text…
I tried using this method:
for (NSString *string in messagearray){
}do{
NSLog(@"happt = %i", b);
b++;
}
while(b == b);
//While loop
while (b == b ) {
NSLog(@"x = %i", b);
b++;
}
}
I would like to count the objects in the array in order to repeat an alloc code for UITextField that number of times, and display the text accordingly, but I am not able. Please help!!
Why can’t you use -count?
b = [messagearray count]To directly answer your question: