Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)loadDataFromWeb {
- NSLog(@"loadDataFromWeb: start");
- // Check for internet connection and alert user if there's none
- NetworkReach = [[InternetReachability alloc] init];
- if (![NetworkReach checkInternet])
- [NetworkReach internetAlert:@"Eatstrong" message:@"Der er ikke oprettet forbindelse til et netværk." cancelButton:@"OK"];
- // Setup parameters
- NSURL *url = [NSURL URLWithString:@"http://www.eatstrong.dk/iphone_recipeList.php"];
- NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];
- NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
- NSError *error = nil;
- // Create dictionaries
- NSDictionary *dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; // Recipes
- // Set recipes
- if (dict)
- {
- self.recipes = dict;
- NSLog(@"Recipes added to dictionary");
- }
- else
- {
- NSLog(@"Error during JSON deserialization. Probably no internet conncetion.");
- }
- // Set keys
- NSArray *array = [[recipes allKeys] sortedArrayUsingSelector:@selector(compare:)];
- self.keys = array;
- NSLog(@"loadDataFromWeb: done");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement