Can I use this technique, or will it get my app rejected by Apple?
- The application starts, downloads some JSON data, and stores it in an array.
- A
UITableViewloads the data from the array. - When the user starts the application again, the application again downloads the JSON data and stores it in the array, and the
UITableViewagain loads the data from the array.
Is this OK, or I should use Core Data to store the data?
Note that some data may change in the JSON, so if I store it using Core Data, it will be difficult for me to track changes and reflect them in Core Data.
PassKit is right, that you should think about what you want the app to do if there’s no Internet connection. Do you want the app to crash or just show nothing at all? Probably better, show the user the last known information, perhaps showing them the date and time that it was last refreshed and/or warn them that it might not be current.
To do that, you will want to save the JSON after it’s successfully downloaded. You don’t need to use Core Data for that (in fact, that’s almost certainly overkill), but you probably do want to save it to your
Documentsfolder. You can just save the JSON object to a file usingwriteToFile. Then, when it tries to retrieve the information from the server at some future date, if it’s not found, look for the information in theDocumentsfolder.