Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Edouard Gabaudan
4,104 PointsJson data slow when server slow
Hi everyone,
I have started the courses and I am currently 'pausing' it to try and practise with my own project.
In this project, I am getting datas from a json file. I used the same code I learned in the Blogpost tutorial:
''' [super viewDidLoad];
NSURL *nodeURL = [NSURL URLWithString:@"http://xxxxxxx/content"];
NSData *jsonData = [NSData dataWithContentsOfURL:nodeURL];
NSError *error = nil;
NSDictionary *nodeDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
self.nodesAll = [NSMutableArray array];
for ( NSDictionary *nDictionary in nodeDictionary) {
Nodes *nodes = [Nodes nodeWithNid:[nDictionary objectForKey:@"nid"]];
nodes.title = [nDictionary objectForKey:@"node_title"];
nodes.email = [nDictionary objectForKey:@"email"];
nodes.image = [nDictionary objectForKey:@"Picture"];
nodes.price = [nDictionary objectForKey:@"price"];
[self.nodesAll addObject:nodes];
}
'''
I am doing several operations with this datas, everything works, except that it is slow. The json file is located on a website hosted on my computer, if I use the local IP address of my computer, it is really fast, no problem, but if I use my public IP, it is slow to do any operations. I don't really understand why, I thought that this code was downloading everything from the json file and that when it was downloaded, we were not suppose to reload any data?
Thanks a lot for your help,
Regards,
Edouard