NSMetadataItem Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.4 and later.
Declared in
NSMetadata.h
NSMetadataAttributes.h
Companion guides
Related sample code

Overview

The NSMetadataItem class represents the metadata associated with a file, providing a simple interface to retrieve the available attribute names and values.

Tasks

Creating a Metadata Item

Getting Item Attributes

Instance Methods

attributes

Returns an array containing the attribute names of the receiver’s values.

- (NSArray *)attributes
Return Value

An array containing the attribute names of the receiver’s values. See the “Constants” section for a list of possible keys.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSMetadata.h

initWithURL:

Initializes a metadata item with a given URL.

- (id)initWithURL:(NSURL *)url
Parameters
url

The URL for the metadata item.

Return Value

A metadata item for the file identified by url.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSMetadata.h

valueForAttribute:

Returns the receiver’s metadata attribute name specified by a given key.

- (id)valueForAttribute:(NSString *)key
Parameters
key

The name of a metadata attribute. See the “Constants” section for a list of possible keys.

Return Value

The receiver’s metadata attribute name specified by key.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSMetadata.h

valuesForAttributes:

Returns a dictionary containing the key-value pairs for the attribute names specified by a given array of keys.

- (NSDictionary *)valuesForAttributes:(NSArray *)keys
Parameters
keys

An array containing NSString objects that specify the names of a metadata attributes. See the “Constants” section for a list of possible keys.

Return Value

A dictionary containing the key-value pairs for the attribute names specified by keys.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSMetadata.h

Constants

Attribute Keys

Attribute keys that may be associated with an item.

NSString * const NSMetadataItemFSNameKey;
NSString * const NSMetadataItemDisplayNameKey;
NSString * const NSMetadataItemURLKey;
NSString * const NSMetadataItemPathKey;
NSString * const NSMetadataItemFSSizeKey;
NSString * const NSMetadataItemFSCreationDateKey;
NSString * const NSMetadataItemFSContentChangeDateKey;
Constants
NSMetadataItemFSNameKey

The value is an NSString object with the name of the item as seen in the file system.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataItemDisplayNameKey

The value is an NSString object with the display name of the item, which may be different then the file system name.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataItemURLKey

The value is an NSURL object that you can use to open the file.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataItemPathKey

The value is an NSString object that contains the full path to the file

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataItemFSSizeKey

The value is an NSNumber object that indicates the size (in bytes) of the file on disk.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataItemFSCreationDateKey

The value is an NSDate object that contains the date and time that the file was created.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataItemFSContentChangeDateKey

The value is an NSDate object that contains the date and time that the file contents last changed.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

Cloud Storage Keys

Attribute keys that describe cloud-related information about the item.

NSString * const NSMetadataItemIsUbiquitousKey;
NSString * const NSMetadataUbiquitousItemHasUnresolvedConflictsKey;
NSString * const NSMetadataUbiquitousItemIsDownloadedKey;
NSString * const NSMetadataUbiquitousItemIsDownloadingKey;
NSString * const NSMetadataUbiquitousItemIsUploadedKey;
NSString * const NSMetadataUbiquitousItemIsUploadingKey;
NSString * const NSMetadataUbiquitousItemPercentDownloadedKey;
NSString * const NSMetadataUbiquitousItemPercentUploadedKey;
NSString * const NSMetadataUbiquitousItemDownloadingStatusKey;
NSString * const NSMetadataUbiquitousItemDownloadingErrorKey;
NSString * const NSMetadataUbiquitousItemUploadingErrorKey;
Constants
NSMetadataItemIsUbiquitousKey

The value is an NSNumber object that contains a Boolean indicating whether the item is stored in the cloud.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemHasUnresolvedConflictsKey

The value is an NSNumber object that contains a Boolean indicating whether the item is currently in conflict with another version of the file somewhere else.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemIsDownloadedKey

The value is an NSNumber object that contains a Boolean indicating whether the current version of the item has been downloaded and is available locally.

This constant is deprecated in iOS 7 and OS X v10.9; use NSMetadataUbiquitousItemDownloadingStatusKey instead.

Available in OS X v10.7 and later.

Deprecated in OS X v10.9.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemIsDownloadingKey

The value is an NSNumber object that contains a Boolean indicating whether the item is currently being downloaded to the local device.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemIsUploadedKey

The value is an NSNumber object that contains a Boolean indicating whether the item has been uploaded to the cloud.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemIsUploadingKey

The value is an NSNumber object that contains a Boolean indicating whether the current version of the item is currently being uploaded to the cloud.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemPercentDownloadedKey

The value is an NSNumber object that contains the percentage of the file that has already been downloaded from the cloud. The value is a double in the range 0.0 to 100.0.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemPercentUploadedKey

The value is an NSNumber object that contains the percentage of the file that has already been uploaded to the cloud. The value is a double in the range 0.0 to 100.0.

Available in OS X v10.7 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemDownloadingStatusKey

The value is a string constant that indicates the download status of the item.

Possible values of the string are given in “Downloading Status Values.”

Available in OS X v10.9 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemDownloadingErrorKey

The value is an NSError object that describes the problem that occurred when downloading the item from iCloud failed.

Available in OS X v10.9 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemUploadingErrorKey

The value is an NSError object that describes the problem that occurred when uploading the item to iCloud failed.

Available in OS X v10.9 and later.

Declared in NSMetadataAttributes.h.

Downloading Status Values

Possible values for the NSMetadataUbiquitousItemDownloadingStatusKey key.

NSString * const NSMetadataUbiquitousItemDownloadingStatusCurrent;
NSString * const NSMetadataUbiquitousItemDownloadingStatusDownloaded;
NSString * const NSMetadataUbiquitousItemDownloadingStatusNotDownloaded;
Constants
NSMetadataUbiquitousItemDownloadingStatusCurrent

A string used as the value for NSMetadataUbiquitousItemPercentUploadedKey to indicate that there is a local version of this item and it is the most up-to-date version known to this device.

Available in OS X v10.9 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemDownloadingStatusDownloaded

A string used as the value for NSMetadataUbiquitousItemPercentUploadedKey to indicate that there is a local version of this item available.

The most current version will be downloaded as soon as possible.

Available in OS X v10.9 and later.

Declared in NSMetadataAttributes.h.

NSMetadataUbiquitousItemDownloadingStatusNotDownloaded

A string used as the value for NSMetadataUbiquitousItemPercentUploadedKey to indicate that this item has not been downloaded yet.

You can use startDownloadingUbiquitousItemAtURL:error: to download the item.

Available in OS X v10.9 and later.

Declared in NSMetadataAttributes.h.