SOExtendedAttributes /

Filename Size Date modified Message
110 B
927 B
1.5 KB
9.3 KB
16.4 KB
3.6 KB
639 B
286 B
579 B


SOExtendedAttributes is a category on NSURL providing methods for manipulating extended attributes on a file system object.

The implementation uses listxattr(2), getxattr(2), setxattr(2), and removexattr(2).


- (BOOL) hasExtendedAttributeWithName:(NSString *)name;

Accessing attributes individually

- (id) valueOfExtendedAttributeWithName:(NSString *)name error:(NSError * __autoreleasing *)outError;
- (BOOL) setExtendedAttributeValue:(id)value forName:(NSString *)name error:(NSError * __autoreleasing *)outError;

Accessing attributes in batch

- (NSDictionary *) extendedAttributesWithError:(NSError * __autoreleasing *)outError;
- (BOOL) setExtendedAttributes:(NSDictionary *)attributes error:(NSError * __autoreleasing *)outError;

Removing an extended attribute

- (BOOL) removeExtendedAttributeWithName:(NSString *)name error:(NSError * __autoreleasing *)outError;

Use with iCloud Backup

Note 2013-06-03: see Apple Tech QA 1719 for the recommended way to mark a file for exclusion from iCloud backup. Hint: don't use the @"" extended attribute.

Extended Attribute Values

An extended attribute value can be any Foundation object that can be serialized into a property list:

  • NSData
  • NSString
  • NSNumber
  • NSArray
  • NSDictionary
  • NSDate

Known Issues, Stuff & Bother

Maximum Value Size

The maximum size of an extended attribute value? I'm not sure, but I believe it is a function of the node size in the HFS+ catalog or attributes tree. The Internet says anywhere from 3802 bytes to 128 KB. So the standard disclaimers apply: Your mileage may vary. Void where prohibited. Do not operate heavy machinery.

Refs: Google Search - OSDir - ArsTechnica 10.4 Review - ArsTechnica 10.6 Review - MacFuse Release Notes

Non-file URLs

An NSInternalInconsistencyException is thrown if these methods are invoked on a non-file URL.

Resolving Symbolic links

These methods act on the explicitly given URL. If that URL points to a symbolic link, you'll be manipulating extended attributes on the symlink, not its original file. Use -URLByResolvingSymlinksInPath to get a URL pointing to the original file system item.


If your project is not using ARC, you will need to set a per-file build flag in Xcode on NSURL+SOExtendedAttributes.m:



For either Mac OS X or iOS projects, add these files:



SOExtendedAttributes is compatible with Mac OS X 10.6+ and iOS 5. The clang compiler is required. The source file NSURL+SOExtendedAttributes.m must be compiled with ARC enabled.

For an alternate Cocoa implementation compatible with Mac OS X 10.4 and greater, see UKXattrMetadataStore.


Bill Garrison, initial creation. @github, @bitbucket

Uli Kusterer, for UKXattrMetadataStore.

Simon Tännler, for starting a Cocoapods spec. @github.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.