I would like to save data to a file every second. The data records is simple, just a date and number, and would like to append to the file. This can last the whole day, so the file can end up being big.
I do not want to block the main thread, nor have concurrency issues. It also has to be capable to being written to in the background, as opposed to the app being in the foreground.
What's the best way forward to achieve this?
You could use Core Data for this. Saving one item per second is not going to impact your app performance at all. Using Core Data will give you ability to query the data, so if you need to show chart from 10 AM to 11 AM from you 24 hours of data for example, it won't be a problem.
Background data collection capability depends on the data source. For example, you can collect location updates in the background. The system provides tools to make this energy efficient. Check http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html