Foundation Data Types Reference
| Framework | Foundation/Foundation.h |
| Declared in | NSAppleEventManager.h NSByteOrder.h NSDate.h NSDecimal.h NSGeometry.h NSHashTable.h NSMapTable.h NSObjCRuntime.h NSPort.h NSRange.h NSString.h NSZone.h |
Overview
This document describes the data types and constants found in the Foundation framework.
Data Types
NSAppleEventManagerSuspensionID
Identifies an Apple event whose handling has been suspended. Can be used to resume handling of the Apple event.
typedef const struct __NSAppleEventManagerSuspension *NSAppleEventManagerSuspensionID;
Availability
- Available in OS X v10.3 and later.
Declared In
NSAppleEventManager.hNSComparator
Defines the signature for a block object used for comparison operations.
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; |
}]; |
Availability
- Available in OS X v10.6 and later.
Declared In
NSObjCRuntime.hNSDecimal
Used to describe a decimal number.
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” in Foundation Functions Reference.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDecimal.hNSHashEnumerator
Allows successive elements of a hash table to be returned each time this structure is passed to NSNextHashEnumeratorItem.
typedef struct {
unsigned _pi;
unsigned _si void *_bs;
} NSHashEnumerator;
Discussion
The fields of NSHashEnumerator are private.
Availability
- Available in OS X v10.0 and later.
Declared In
NSHashTable.hNSHashTable
The opaque data type used by the functions described in “Hash Tables” in Foundation Functions Reference.
typedef struct _NSHashTable NSHashTable;
Discussion
For OS X v10.5 and later, see also NSHashTable.
Availability
- Available in OS X v10.0 through OS X v10.4.
Declared In
NSHashTable.hNSHashTableCallBacks
Defines a structure that contains the function pointers used to configure behavior of NSHashTable with respect to elements within a hash table.
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;
Fields
hashPoints to the function that must produce hash code for elements of the hash table. If
NULL, the pointer value is used as the hash code. Second parameter is the element for which hash code should be produced.isEqualPoints to the function that compares second and third parameters. If
NULL, then == is used for comparison.retainPoints to the function that increments a reference count for the given element. If
NULL, then nothing is done for reference counting.releasePoints to the function that decrements a reference count for the given element, and if the reference count becomes 0, frees the given element. If
NULL, then nothing is done for reference counting or releasing.describePoints to the function that produces an autoreleased NSString * describing the given element. If
NULL, then the hash table produces a generic string description.
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSHashTable.hNSHashTableOptions
Specifies a bitfield used to configure the behavior of elements in an instance of NSHashTable.
typedef NSUInteger NSHashTableOptions
Availability
- Available in OS X v10.5 and later.
Declared In
NSHashTable.hNSInteger
Used to describe an integer.
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.
Availability
- Available in OS X v10.5 and later.
Declared In
NSObjCRuntime.hNSMapEnumerator
Allows successive elements of a map table to be returned each time this structure is passed to NSNextMapEnumeratorPair.
typedef struct {
unsigned _pi;
unsigned _si;
void *_bs;
} NSMapEnumerator;
Discussion
The fields of NSMapEnumerator are private.
Availability
- Available in OS X v10.0 and later.
Declared In
NSMapTable.hNSMapTable
The opaque data type used by the functions described in “Managing Map Tables” in Foundation Functions Reference.
typedef struct _NSMapTable NSMapTable;
Discussion
For OS X v10.5 and later, see also NSMapTable.
Availability
- Available in OS X v10.0 through OS X v10.4.
Declared In
NSMapTable.hNSMapTableKeyCallBacks
The function pointers used to configure behavior of NSMapTable with respect to key elements within a map table.
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;
Fields
hashPoints to the function which must produce hash code for key elements of the map table. If
NULL, the pointer value is used as the hash code. Second parameter is the element for which hash code should be produced.isEqualPoints to the function which compares second and third parameters. If
NULL, then == is used for comparison.retainPoints to the function which increments a reference count for the given element. If
NULL, then nothing is done for reference counting.releasePoints to the function which decrements a reference count for the given element, and if the reference count becomes zero, frees the given element. If
NULL, then nothing is done for reference counting or releasing.describePoints to the function which produces an autoreleased NSString * describing the given element. If
NULL, then the map table produces a generic string description.notAKeyMarkerNo key put in map table can be this value. An exception is raised if attempt is made to use this value as a key
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSMapTable.hNSMapTableOptions
Specifies a bitfield used to configure the behavior of elements in an instance of NSMapTable.
typedef NSUInteger NSMapTableOptions
Availability
- Available in OS X v10.5 and later.
Declared In
NSMapTable.hNSMapTableValueCallBacks
The function pointers used to configure behavior of NSMapTable with respect to value elements within a map table.
typedef struct {
void (*retain)(NSMapTable *table, const void *);
void (*release)(NSMapTable *table, void *);
NSString *(*describe)(NSMapTable *table, const void *);
} NSMapTableValueCallBacks;
Fields
retainPoints to the function that increments a reference count for the given element. If
NULL, then nothing is done for reference counting.releasePoints to the function that decrements a reference count for the given element, and if the reference count becomes zero, frees the given element. If
NULL, then nothing is done for reference counting or releasing.describePoints to the function that produces an autoreleased NSString * describing the given element. If
NULL, then the map table produces a generic string description.
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.
Availability
- Available in OS X v10.0 and later.
Declared In
NSMapTable.hNSPoint
Represents a point in a Cartesian coordinate system.
typedef struct _NSPoint {
CGFloat x;
CGFloat y;
} NSPoint;
Fields
xThe x coordinate.
yThe y coordinate.
Special Considerations
Prior to OS X v10.5 the coordinates were represented by float values rather than CGFloat values.
When building for 64 bit systems, or building 32 bit like 64 bit, NSPoint is typedef’d to CGPoint.
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSPointArray
Type indicating a parameter is array of NSPoint structures.
typedef NSPoint *NSPointArray;
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSPointPointer
Type indicating a parameter is a pointer to an NSPoint structure.
typedef NSPoint *NSPointPointer;
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSRange
A structure used to describe a portion of a series—such as characters in a string or objects in an NSArray object.
typedef struct _NSRange {
NSUInteger location;
NSUInteger length;
} NSRange;
Fields
locationThe start index (
0is the first, as in C arrays).lengthThe number of items in the range (can be
0).
Discussion
Foundation functions that operate on ranges include the following:
Availability
- Available in OS X v10.0 and later.
Declared In
NSRange.hNSRangePointer
Type indicating a parameter is a pointer to an NSRange structure.
typedef NSRange *NSRangePointer;
Availability
- Available in OS X v10.0 and later.
Declared In
NSRange.hNSRect
Represents a rectangle.
typedef struct _NSRect {
NSPoint origin;
NSSize size;
} NSRect;
Fields
originThe origin of the rectangle (its starting x coordinate and y coordinate).
sizeThe width and height of the rectangle, as measured from the origin.
Special Considerations
When building for 64 bit systems, or building 32 bit like 64 bit, NSRect is typedef’d to CGRect.
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSRectArray
Type indicating a parameter is array of NSRect structures.
typedef NSRect *NSRectArray;
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSRectPointer
Type indicating a parameter is a pointer to an NSRect structure.
typedef NSRect *NSRectPointer;
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSSize
Represents a two-dimensional size.
typedef struct _NSSize {
CGFloat width;
CGFloat height;
} NSSize;
Fields
widthThe width.
heightThe height.
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.
Special Considerations
Prior to OS X v10.5 the width and height were represented by float values rather than CGFloat values.
When building for 64 bit systems, or building 32 bit like 64 bit, NSSize is typedef’d to CGSize.
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSSizeArray
Type indicating a parameter is an array of NSSize structures.
typedef NSSize *NSSizeArray;
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSSizePointer
Type indicating parameter is a pointer to an NSSize structure.
typedef NSSize *NSSizePointer;
Availability
- Available in OS X v10.0 and later.
Declared In
NSGeometry.hNSSocketNativeHandle
Type for the platform-specific native socket handle.
typedef int NSSocketNativeHandle;
Availability
- Available in OS X v10.0 and later.
Declared In
NSPort.hNSStringEncoding
Type representing string-encoding values.
typedef NSUInteger NSStringEncoding;
Discussion
See String Encodings for a list of values.
Availability
- Available in OS X v10.0 and later.
Declared In
NSString.hNSSwappedDouble
Opaque structure containing endian-independent double value.
typedef struct {
unsigned long long v;
} NSSwappedDouble;
Discussion
The fields of an NSSwappedDouble are private.
Availability
- Available in OS X v10.0 and later.
Declared In
NSByteOrder.hNSSwappedFloat
Opaque type containing an endian-independent float value.
typedef struct {
unsigned int v;
} NSSwappedFloat;
Discussion
The fields of an NSSwappedFloat are private.
Availability
- Available in OS X v10.0 and later.
Declared In
NSByteOrder.hNSTimeInterval
Used to specify a time interval, in seconds.
typedef double NSTimeInterval;
Discussion
NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDate.hNSUncaughtExceptionHandler
Used for the function handling exceptions outside of an exception-handling domain.
typedef volatile void NSUncaughtExceptionHandler(NSException *exception);
Discussion
You can set exception handlers using NSSetUncaughtExceptionHandler.
Declared In
NSException.hNSUInteger
Used to describe an unsigned integer.
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
Availability
- Available in OS X v10.5 and later.
Declared In
NSObjCRuntime.hNSZone
Used to identify and manage memory zones.
typedef struct _NSZone NSZone;
Availability
- Available in OS X v10.0 and later.
Declared In
NSZone.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-17)