objective c - What is the best way to load static objects in an iOS app? -


i have list of 100 address. want use clgeocoder class , geocodeaddressdictionary or geocodeaddressstring methods list of clplacemarks each address. don't want app every time starts (as addresses never change , requires internet). how can statically store list of 100 clplacemark objects loaded each time app launches?

i suggest:

store list in app bundle .plist file or json file can parsed on launch static nsdictionary or instance variable of singleton object.

first serialise 100 addresses json file. can try use online tools like: http://www.objgen.com/json

once have text json file drag file project in xcode. can parse using:

nserror *error; nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"addresses" oftype:@"json"];   nsurl *localfileurl = [nsurl fileurlwithpath:filepath]; nsdata *contentoflocalfile = [nsdata datawithcontentsofurl:localfileurl]; nsdictionary *addresses = [nsjsonserialization jsonobjectwithdata:contentoflocalfile                                              options: nsjsonreadingmutablecontainers                                                error:&error]; 

you can use same method deserialise plist file.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -