Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Last active April 3, 2016 17:10
Show Gist options
  • Save hansemannn/676a9c7ca35c2f29212d19bddd4a135a to your computer and use it in GitHub Desktop.
Save hansemannn/676a9c7ca35c2f29212d19bddd4a135a to your computer and use it in GitHub Desktop.
-(NSNumber*)remoteBackup
{
NSURL *URL= [NSURL fileURLWithPath: [self path]];
NSError *error;
NSNumber *result = nil;
BOOL success = [URL getResourceValue:&result
forKey:NSURLIsExcludedFromBackupKey error:&error];
if (!success) {
// Doesn't matter what error is set to; this means that we're backing up.
return NUMBOOL(YES);
}
// A value of 0 means backup, so:
return NUMBOOL([result isEqualToNumber:@YES] ? NO : YES);
}
-(void)setRemoteBackup:(id)remoteBackup
{
ENSURE_TYPE(remoteBackup, NSNumber);
BOOL isExcluced = ![TiUtils boolValue:remoteBackup def:YES];
NSURL *URL= [NSURL fileURLWithPath: [self path]];
NSError *error;
BOOL success = [URL setResourceValue: NUMBOOL(isExcluced)
forKey: NSURLIsExcludedFromBackupKey error: &error];
if (!success) {
[self throwException:@"Error setting remote backup flag:"
subreason:[error localizedDescription]
location:CODELOCATION];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment