0

As the title says, does JSONModel arrayOfModelsFromDictionaries returns null, it works fine on the simulator, but not on the device. My JSON has the following structure:

[{"data1":"a","data2":"b"},{"data1":"a","data2":"b"}] 

I have two JSONModel subclasses one called Restaurant & RestaurantFeed (Like in the Kivafeed example, in order to use the convertOnDemand feature (Which doesn't work either, maybe because of the direct initialization when using arrayOfModelsFromDictionaries ) and I receive the data like so

[JSONHTTPClient getJSONFromURLWithString:URL
                                       params:nil
                                   completion:^(id json, JSONModelError *err) {

                                       NSArray *arrays = [Restaurant arrayOfModelsFromDictionaries:json];
                                        NSLog(@"%@ %@", self.feed, err);
                                       self.feed.restaurants = arrays;

                                       [self.restaurantsTableView reloadData];

                                   }];

How can I fix this?

  • URL..? ensure not localhost ??? and check the internet connection on device.. – Kumar KL Oct 26 '13 at 10:47
  • It is not localhost, and the device has a working internet connection (3G & WI-FI). I have tried to use the following url: http://api.matematikfessor.dk/apps/teacher_videos from this question http://stackoverflow.com/questions/18890762/jsonmodel-returns-nil/18902696#18902696. This JSON has the same structure, but it is not working on my device either. – 7c9d6b001a87e497d6b96fbd4c6fdf Oct 26 '13 at 10:50
  • so if you do NSLog(@"%@", json); how does that look like? – Marin Todorov Oct 26 '13 at 17:11
  • For some reason it worked after I updated Xcode to the new version. Thank you for the help. @Ican Zilb are the creator of JSONModel? If yes, thank you for this beautiful "tool". Can you please confirm that the convertOnDemand feature works when using arrayOfModelsFromDictionaries? because it dosen't seems like it does. It seems like it is initialization all models at the same time. – 7c9d6b001a87e497d6b96fbd4c6fdf Oct 26 '13 at 20:24
  • hey yeah :) it's me :) arrayOfModelsFromDictionaries shouldn't have to do anything with convertsondemand. convertsondemand is relevant to the nsarray property found in a model class, not your list of models for which you use arrayOfModelsFromDictionaries: – Marin Todorov Oct 27 '13 at 09:01
  • Thank you for the answer. For some reason it only worked once (arrayOfModelsFromDictionaries), yesterday and I am now stuck with the problem again, it doesn't work on the device. If I NSLog the json, I get the following data: ( { Info = "10-13"; Adresse = "NY"; Id = 47; }) .. I have tracked the problem down to the following in the method: id obj = [[self alloc] initWithDictionary:d error:&initErr];, it doesn't seem to make it an dictionary. Any ideas, why this happen? – 7c9d6b001a87e497d6b96fbd4c6fdf Oct 27 '13 at 10:15

0 Answers0