Mac Developer Library

Developer

AppKit Framework Reference NSFileWrapper AppKit Additions Reference

Options
Deployment Target:

On This Page
Language:

NSFileWrapper

Inheritance


Not Applicable

Conforms To


  • NSCoding (NSFileWrapper)

  • NSObject (NSObject)

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

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.

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

    Declaration

    Swift

    var icon: NSImage?

    Objective-C

    @property(strong) 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setIcon:

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

    Declaration

    Swift

    var icon: NSImage?

    Objective-C

    @property(strong) 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – icon