Skip to content

Instantly share code, notes, and snippets.

@billibala
Last active December 20, 2015 01:39
Show Gist options
  • Save billibala/6050984 to your computer and use it in GitHub Desktop.
Save billibala/6050984 to your computer and use it in GitHub Desktop.
Mac/iOS - Checks whether a file URL is a document package, regular or a folder.
// Assume base path is your Desktop
NSURL * baseFileURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDesktopDirectory inDomains:NSUserDomainMask] lastObject];
NSURL * fileURL = [baseFileURL URLByAppendingPathComponent:@"__FILE_NAME__"];
// the keys we are interested in
NSArray * attrArray = @[NSURLIsPackageKey, NSURLIsRegularFileKey, NSURLIsWritableKey, NSURLIsDirectoryKey];
NSDictionary * theDict = [fileURL resourceValuesForKeys:attrArray error:nil];
NSLog(@"the dict: %@", theDict);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment