I want to persist 2 CLLocations between app launches. This is the ONLY data I want stored in memory between launches. How do I go about doing this? Does CLLocation have a writetofile or store it in coredata or NSUserDefaults? I want to store the whole CLLocation object, don’t want to store only lat/lon and then do more calculations etc. Thanks
Share
Looking at the documentation I see that
CLLocationimplements theNSCodingprotocol.This means that you can archive and unarchive a
CLLocationinstance by using theNSKeyedArchiverandNSKeyedUnarchiverclasses.You can also put multiple instances of
CLLocationin any container (parent) class that implementsNSCoderlike for exampleNSDictionaryorNSArrayand then archive or unarchive that whole collection of objects.See the Archives and Serializations Programming Guide for more detailed info. Or post a followup question with code if you get stuck.