Writing iPhone filesystem in background mode
I am writing an app that logs GPS locations to a file on the iPhone and has to continue updating the locations in background mode. Now I am wondering what is the best way of doing this. Is it good practice to open the file and ke开发者_高级运维ep it open when my app goes in to background mode or should I close it and re-open it whenever the app needs to write a new location?
Why keeping open/re-opening the file?
You can let it "write" the location data to an NSMutableArray
and write it to a file before your App gets killed or if the user manually saves it by pressing a button.
As drachenstern already mentioned, it will suck the battery dry to have location services on all the time...might lead to a bad UX
精彩评论