New file attribute for non-purgeable, non-backed up files
New file attribute for non-purgeable,non-backed up files
iOS 5.0.1 beta introduces a new "do not back up" attribute for specifying files that shouldremain on device, even in low storage situations. Use this attribute with data that can berecreated but needs to persist even in low storage situations for proper functioning of your appor because customers expect it to be available during offline use. This attribute works onmarked files regardless of what directory they are in, including the Documents directory. Thesefiles will not be purged and will not be included in the user's iCloud or iTunes backup. Becausethese files do use on-device storage space, your app is responsible for monitoring and purgingthese files periodically.
To set the "do not back up" attribute, add the following method to a class in your application.Whenever you create a file that should not be backed up to iCloud, write the data to the fileand then call this method, passing in a URL that points to the file.
<pre class="brush:objc; toolbar: true; auto-links: false;">
- (void) AddSkipBackupAttributeToFile: (NSURL*) url
u_int8_t b = 1;
setxattr([[url path] fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);