Mac Developer Library

Developer

Foundation Framework Reference Foundation Data Types Reference

Options
Deployment Target:

On This Page
Language:

Foundation Data Types Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

This document describes the data types and constants found in the Foundation framework.

Data Types

  • Identifies an Apple event whose handling has been suspended. Can be used to resume handling of the Apple event.

    Declaration

    Swift

    typealias NSAppleEventManagerSuspensionID = COpaquePointer

    Objective-C

    typedef const struct __NSAppleEventManagerSuspension *NSAppleEventManagerSuspensionID;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.3 and later.

  • Defines the signature for a block object used for comparison operations.

    Declaration

    Swift

    typealias NSComparator = (AnyObject!, AnyObject!) -> NSComparisonResult

    Objective-C

    typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);

    Discussion

    The arguments to the block are two objects to compare. The block returns an NSComparisonResult value to denote the ordering of the two objects.

    You use NSComparator blocks in comparison operations such as NSArray’s sortedArrayUsingComparator:, for example:

    • NSArray *sortedArray = [array sortedArrayUsingComparator: ^(id obj1, id obj2) {
    • if ([obj1 integerValue] > [obj2 integerValue]) {
    • return (NSComparisonResult)NSOrderedDescending;
    • }
    • if ([obj1 integerValue] < [obj2 integerValue]) {
    • return (NSComparisonResult)NSOrderedAscending;
    • }
    • return (NSComparisonResult)NSOrderedSame;
    • }];

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.6 and later.

  • Used to describe a decimal number.

    Declaration

    Swift

    struct NSDecimal { var _mantissa: (UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16) init() }

    Objective-C

    typedef struct { signed int _exponent:8; unsigned int _length:4; unsigned int _isNegative:1; unsigned int _isCompact:1; unsigned int _reserved:18; unsigned short _mantissa[NSDecimalMaxSize]; } NSDecimal;

    Discussion

    The fields of NSDecimal are private.

    Used by the functions described in Decimals.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Allows successive elements of a hash table to be returned each time this structure is passed to NSNextHashEnumeratorItem.

    Declaration

    Swift

    struct NSHashEnumerator { var _pi: Int var _si: Int var _bs: UnsafeMutablePointer<Void> init() init(_pi _pi: Int, _si _si: Int, _bs _bs: UnsafeMutablePointer<Void>) }

    Objective-C

    typedef struct { unsigned _pi; unsigned _si void *_bs; } NSHashEnumerator;

    Discussion

    The fields of NSHashEnumerator are private.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • The opaque data type used by the functions described in Hash Tables.

    Declaration

    Objective-C

    typedef struct _NSHashTable NSHashTable;

    Discussion

    For OS X v10.5 and later, see also NSHashTable.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in OS X v10.0 through OS X v10.4.

    Not available to 64-bit applications.

  • Defines a structure that contains the function pointers used to configure behavior of NSHashTable with respect to elements within a hash table.

    Declaration

    Swift

    struct NSHashTableCallBacks { var hash: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>) -> Int)> var isEqual: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>, UnsafePointer<Void>) -> Bool)> var retain: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>) -> Void)> var release: CFunctionPointer<((NSHashTable!, UnsafeMutablePointer<Void>) -> Void)> var describe: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>) -> String!)> init() init(hash hash: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>) -> Int)>, isEqual isEqual: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>, UnsafePointer<Void>) -> Bool)>, retain retain: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>) -> Void)>, release release: CFunctionPointer<((NSHashTable!, UnsafeMutablePointer<Void>) -> Void)>, describe describe: CFunctionPointer<((NSHashTable!, UnsafePointer<Void>) -> String!)>) }

    Objective-C

    typedef struct { unsigned (*hash)(NSHashTable *table, const void *); BOOL (*isEqual)(NSHashTable *table, const void *, const void *); void (*retain)(NSHashTable *table, const void *); void (*release)(NSHashTable *table, void *); NSString *(*describe)(NSHashTable *table, const void *); } NSHashTableCallBacks;

    Discussion

    All functions must know the types of things in the hash table to be able to operate on them. Sets of predefined call backs are described in NSHashTable Class Reference.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Specifies a bitfield used to configure the behavior of elements in an instance of NSHashTable.

    Declaration

    Swift

    typealias NSHashTableOptions = Int

    Objective-C

    typedef NSUInteger NSHashTableOptions

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.5 and later.

  • Used to describe an integer.

    Declaration

    Swift

    typealias NSInteger = Int

    Objective-C

    typedef long NSInteger;

    Discussion

    When building 32-bit applications, NSInteger is a 32-bit integer. A 64-bit application treats NSInteger as a 64-bit integer.

    Import Statement

    Objective-C

    @import ObjectiveC;

    Swift

    import ObjectiveC

    Availability

    Available in OS X v10.5 and later.

  • Allows successive elements of a map table to be returned each time this structure is passed to NSNextMapEnumeratorPair.

    Declaration

    Swift

    struct NSMapEnumerator { var _pi: Int var _si: Int var _bs: UnsafeMutablePointer<Void> init() init(_pi _pi: Int, _si _si: Int, _bs _bs: UnsafeMutablePointer<Void>) }

    Objective-C

    typedef struct { unsigned _pi; unsigned _si; void *_bs; } NSMapEnumerator;

    Discussion

    The fields of NSMapEnumerator are private.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • The opaque data type used by the functions described in Managing Map Tables.

    Declaration

    Objective-C

    typedef struct _NSMapTable NSMapTable;

    Discussion

    For OS X v10.5 and later, see also NSMapTable.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in OS X v10.0 through OS X v10.4.

    Not available to 64-bit applications.

  • The function pointers used to configure behavior of NSMapTable with respect to key elements within a map table.

    Declaration

    Swift

    struct NSMapTableKeyCallBacks { var hash: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> Int)> var isEqual: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>, UnsafePointer<Void>) -> Bool)> var retain: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> Void)> var release: CFunctionPointer<((NSMapTable!, UnsafeMutablePointer<Void>) -> Void)> var describe: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> String!)> var notAKeyMarker: UnsafePointer<Void> init() init(hash hash: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> Int)>, isEqual isEqual: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>, UnsafePointer<Void>) -> Bool)>, retain retain: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> Void)>, release release: CFunctionPointer<((NSMapTable!, UnsafeMutablePointer<Void>) -> Void)>, describe describe: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> String!)>, notAKeyMarker notAKeyMarker: UnsafePointer<Void>) }

    Objective-C

    typedef struct { unsigned (*hash)(NSMapTable *table, const void *); BOOL (*isEqual)(NSMapTable *table, const void *, const void *); void (*retain)(NSMapTable *table, const void *); void (*release)(NSMapTable *table, void *); NSString *(*describe)(NSMapTable *table, const void *); const void *notAKeyMarker; } NSMapTableKeyCallBacks;

    Discussion

    All functions must know the types of things in the map table to be able to operate on them. Sets of predefined call backs are described in NSMapTable Class Reference.

    Two predefined values to use for notAKeyMarker are NSNotAnIntMapKey and NSNotAPointerMapKey.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Specifies a bitfield used to configure the behavior of elements in an instance of NSMapTable.

    Declaration

    Swift

    typealias NSMapTableOptions = Int

    Objective-C

    typedef NSUInteger NSMapTableOptions

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.5 and later.

  • The function pointers used to configure behavior of NSMapTable with respect to value elements within a map table.

    Declaration

    Swift

    struct NSMapTableValueCallBacks { var retain: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> Void)> var release: CFunctionPointer<((NSMapTable!, UnsafeMutablePointer<Void>) -> Void)> var describe: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> String!)> init() init(retain retain: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> Void)>, release release: CFunctionPointer<((NSMapTable!, UnsafeMutablePointer<Void>) -> Void)>, describe describe: CFunctionPointer<((NSMapTable!, UnsafePointer<Void>) -> String!)>) }

    Objective-C

    typedef struct { void (*retain)(NSMapTable *table, const void *); void (*release)(NSMapTable *table, void *); NSString *(*describe)(NSMapTable *table, const void *); } NSMapTableValueCallBacks;

    Discussion

    All functions must know the types of things in the map table to be able to operate on them. Sets of predefined call backs are described in NSMapTable Class Reference.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Represents a point in a Cartesian coordinate system.

    Declaration

    Swift

    typealias NSPoint = CGPoint

    Objective-C

    typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating a parameter is array of NSPoint structures.

    Declaration

    Swift

    typealias NSPointArray = UnsafeMutablePointer<NSPoint>

    Objective-C

    typedef NSPoint *NSPointArray;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating a parameter is a pointer to an NSPoint structure.

    Declaration

    Swift

    typealias NSPointPointer = UnsafeMutablePointer<NSPoint>

    Objective-C

    typedef NSPoint *NSPointPointer;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • A structure used to describe a portion of a series—such as characters in a string or objects in an NSArray object.

    Declaration

    Swift

    typealias NSRange = _NSRange

    Objective-C

    typedef struct _NSRange { NSUInteger location; NSUInteger length; } NSRange;

    Discussion

    Foundation functions that operate on ranges include the following:

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating a parameter is a pointer to an NSRange structure.

    Declaration

    Swift

    typealias NSRangePointer = UnsafeMutablePointer<NSRange>

    Objective-C

    typedef NSRange *NSRangePointer;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Represents a rectangle.

    Declaration

    Swift

    typealias NSRect = CGRect

    Objective-C

    typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating a parameter is array of NSRect structures.

    Declaration

    Swift

    typealias NSRectArray = UnsafeMutablePointer<NSRect>

    Objective-C

    typedef NSRect *NSRectArray;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating a parameter is a pointer to an NSRect structure.

    Declaration

    Swift

    typealias NSRectPointer = UnsafeMutablePointer<NSRect>

    Objective-C

    typedef NSRect *NSRectPointer;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Represents a two-dimensional size.

    Declaration

    Swift

    typealias NSSize = CGSize

    Objective-C

    typedef struct _NSSize { CGFloat width; CGFloat height; } NSSize;

    Discussion

    Normally, the values of width and height are non-negative. The functions that create an NSSize structure do not prevent you from setting a negative value for these attributes. If the value of width or height is negative, however, the behavior of some methods may be undefined.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating a parameter is an array of NSSize structures.

    Declaration

    Swift

    typealias NSSizeArray = UnsafeMutablePointer<NSSize>

    Objective-C

    typedef NSSize *NSSizeArray;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type indicating parameter is a pointer to an NSSize structure.

    Declaration

    Swift

    typealias NSSizePointer = UnsafeMutablePointer<NSSize>

    Objective-C

    typedef NSSize *NSSizePointer;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type for the platform-specific native socket handle.

    Declaration

    Swift

    typealias NSSocketNativeHandle = Int32

    Objective-C

    typedef int NSSocketNativeHandle;

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Type representing string-encoding values.

    Declaration

    Objective-C

    typedef NSUInteger NSStringEncoding;

    Discussion

    See String Encodings for a list of values.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in OS X v10.0 and later.

  • Opaque structure containing endian-independent double value.

    Declaration

    Swift

    struct NSSwappedDouble { var v: UInt64 init() init(v v: UInt64) }

    Objective-C

    typedef struct { unsigned long long v; } NSSwappedDouble;

    Discussion

    The fields of an NSSwappedDouble are private.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Opaque type containing an endian-independent float value.

    Declaration

    Swift

    struct NSSwappedFloat { var v: UInt32 init() init(v v: UInt32) }

    Objective-C

    typedef struct { unsigned int v; } NSSwappedFloat;

    Discussion

    The fields of an NSSwappedFloat are private.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Used to specify a time interval, in seconds.

    Declaration

    Swift

    typealias NSTimeInterval = Double

    Objective-C

    typedef double NSTimeInterval;

    Discussion

    NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Used for the function handling exceptions outside of an exception-handling domain.

    Declaration

    Objective-C

    typedef volatile void NSUncaughtExceptionHandler(NSException *exception);

    Discussion

    You can set exception handlers using NSSetUncaughtExceptionHandler.

    Import Statement

  • Used to describe an unsigned integer.

    Declaration

    Objective-C

    typedef unsigned long NSUInteger;

    Discussion

    When building 32-bit applications, NSUInteger is a 32-bit unsigned integer. A 64-bit application treats NSUInteger as a 64-bit unsigned integer

    Import Statement

    Objective-C

    @import ObjectiveC;

    Availability

    Available in OS X v10.5 and later.

  • Used to identify and manage memory zones.

    Declaration

    Objective-C

    typedef struct _NSZone NSZone;

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in OS X v10.0 and later.