NSFileWrapper AppKit Additions Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Companion guide
Declared in
NSFileWrapperExtensions.h

Overview

Application Kit extends Foundation’s NSFileWrapper class by adding support for attaching icons to the file wrapper. The icon represents a node in a document and can be used dragging operations.

See NSFileWrapper Class Reference for the remainder of the class that resides in Foundation Kit.

Tasks

Getting and Setting the Icon

Instance Methods

icon

Returns an icon that represents the file wrapper to the user.

- (NSImage *)icon
Return Value

Icon that represents the file wrapper; nil when the file wrapper has no icon.

Discussion

You don’t have to use this icon; for example, a file viewer typically looks up icons automatically based on file extensions, and so wouldn’t need this one. Similarly, if a file wrapper represents an image file, you can display the image directly rather than a file icon.

This method may return nil if the file wrapper is a child created when its parent was read from the file system, and the child was modified before it was read. Use the NSFileWrapperReadingImmediate reading option to reduce the likelihood of that problem.

Because the NSImage object that's returned might be shared by many NSFileWrapper objects, you must not mutate it. If you need to mutate the returned object, make a copy first and mutate the copy instead.

Availability
  • Available in OS X v10.0 and later.
See Also
Related Sample Code
Declared In
NSFileWrapperExtensions.h

setIcon:

Specifies an image that can be used to represent the file wrapper to the user.

- (void)setIcon:(NSImage *)icon
Parameters
icon

Image that can be used to represent the file wrapper to the user.

Discussion

An application does not have to use this icon; for example, a file viewer typically looks up icons automatically based on file extensions, and so wouldn’t need this one. Similarly, if a file wrapper represents an image file, an application can display the image directly rather than a file icon.

Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSFileWrapperExtensions.h