This is my problem, I'm building an iOS with some JSON returs from my server, here, no problems, all works fine.
The problem is that when I run the program, it take a long long time to parse the result into a NSMutableArray
: this is the log
2013-01-10 12:03:48.627 project[5917:907] <- time begin parser
2013-01-10 12:03:48.755 project[5917:907] <- time finish parser
2013-01-10 12:03:48.756 project[5917:907] <- time begin implement arrays
2013-01-10 12:03:58.522 project[5917:907] <- time finish implement array
As you can see, implementing the arrays is really long.
I know that I have to use queueing and grand central dispatch to make my UI responsive, but I don't know how to, could you please help me to do that ?
This is my viewDidLoad
Method
- (void)viewDidLoad
{
[super viewDidLoad];
if debug
NSLog(@"<- time begin parser");
endif
NSString *URLStr = @"http://myJsonFile.json";
NSDictionary *myDictwithReturn = [TOCJSONParser awesomeParserWithStringOfYourJSONFile:URLStr]; //really cool parser, i can put it on gitHub if you want
NSArray *speakersArray = [myDictwithReturn objectForKey:@"speakers"];
myArray = [[NSMutableArray alloc]init];
NSLog(@"<- time finish parser");
NSLog(@"<- time begin implement arrays");
for (NSDictionary *myDict in speakersArray) {
_nextSpeaker = [[TOCSpk alloc]init];
[_nextSpeaker setName:[myDict objectForKey:@"name"]];
[_nextSpeaker setBusiness:[myDict objectForKey:@"business"]];
[_nextSpeaker setDesc:[myDict objectForKey:@"desc"]];
[_nextSpeaker setTwitter:[NSURL URLWithString:[myDict objectForKey:@"twitter"]]];
[_nextSpeaker setPicture:[_nextSpeaker retrieveImageFromServer:[myDict objectForKey:@"picture"]]];
[myArray addObject:_nextSpeaker];
}
NSLog(@"<- time finish implement array");
}