iPhone OS Reference Library Apple Developer Connection spyglass button

Foundation Data Types Reference

Framework
Foundation/Foundation.h
Declared in
NSByteOrder.h
NSDate.h
NSDecimal.h
NSException.h
NSObjCRuntime.h
NSPathUtilities.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

NSByteOrder

These constants specify an endian format.

enum _NSByteOrder {
   NS_UnknownByteOrder = CFByteOrderUnknown,
   NS_LittleEndian = CFByteOrderLittleEndian,
   NS_BigEndian = CFByteOrderBigEndian
};
Constants
NS_UnknownByteOrder

The byte order is unknown.

Available in iPhone OS 2.0 and later.

Declared in NSByteOrder.h.

NS_LittleEndian

The byte order is little endian.

Available in iPhone OS 2.0 and later.

Declared in NSByteOrder.h.

NS_BigEndian

The byte order is big endian.

Available in iPhone OS 2.0 and later.

Declared in NSByteOrder.h.

Discussion

These constants are returned by NSHostByteOrder.

NSComparator

Defines the signature for a Block used for comparison operations.

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

You use NSComparator Blocks in comparison operations such as NSArray’s indexOfObject:inSortedRange:options:usingComparator:.

NSComparisonResult

These constants are used to indicate how items in a request are ordered.

enum {
   NSOrderedAscending = -1,
   NSOrderedSame,
   NSOrderedDescending
};
typedef NSInteger NSComparisonResult;
Constants
NSOrderedAscending

The left operand is smaller than the right operand.

Available in iPhone OS 2.0 and later.

Declared in NSObjCRuntime.h.

NSOrderedSame

The two operands are equal.

Available in iPhone OS 2.0 and later.

Declared in NSObjCRuntime.h.

NSOrderedDescending

The left operand is greater than the right operand.

Available in iPhone OS 2.0 and later.

Declared in NSObjCRuntime.h.

Discussion

These constants are used to indicate how items in a request are ordered, from the first one given in a method invocation or function call to the last (that is, left to right in code).

Availability
Declared In
NSObjCRuntime.h

NSDecimal

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".

Availability
Declared In
NSDecimal.h

NSHashTableOptions

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

typedef NSUInteger NSHashTableOptions
Declared In
NSHashTable.h

NSInteger

Used to describe an integer.

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
#else
typedef int NSInteger;
#endif
Discussion

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

Availability
Declared In
NSObjCRuntime.h

NSMapTableOptions

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

typedef NSUInteger NSMapTableOptions
Declared In
NSMapTable.h

NSRange

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
location

The start index (0 is the first, as in C arrays).

length

The number of items in the range (can be 0).

Discussion

Foundation functions that operate on ranges include the following:

Availability
Declared In
NSRange.h

NSRangePointer

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

typedef NSRange *NSRangePointer;
Availability
Declared In
NSRange.h

NSSearchPathDirectory

These constants specify the location of a variety of directories.

enum {
   NSApplicationDirectory = 1,
   NSDemoApplicationDirectory,
   NSDeveloperApplicationDirectory,
   NSAdminApplicationDirectory,
   NSLibraryDirectory,
   NSDeveloperDirectory,
   NSUserDirectory,
   NSDocumentationDirectory,
   NSDocumentDirectory,
   NSCoreServiceDirectory,
   NSAutosavedInformationDirectory = 11,
   NSDesktopDirectory = 12,
   NSCachesDirectory = 13,
   NSApplicationSupportDirectory = 14,
   NSDownloadsDirectory = 15,
   NSInputMethodsDirectory = 16,
   NSMoviesDirectory = 17,
   NSMusicDirectory = 18,
   NSPicturesDirectory = 19,
   NSPrinterDescriptionDirectory = 20,
   NSSharedPublicDirectory = 21,
   NSPreferencePanesDirectory = 22,
   NSItemReplacementDirectory = 99,
   NSAllApplicationsDirectory = 100,
   NSAllLibrariesDirectory = 101
};
typedef NSUInteger NSSearchPathDirectory;
Constants
NSApplicationDirectory

Supported applications (/Applications).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDemoApplicationDirectory

Unsupported applications and demonstration versions.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDeveloperApplicationDirectory

Developer applications (/Developer/Applications).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSAdminApplicationDirectory

System and network administration applications.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSLibraryDirectory

Various user-visible documentation, support, and configuration files (/Library).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDeveloperDirectory

Developer resources (/Developer).

Deprecated: Beginning with Xcode 3.0, developer tools can be installed in any location.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSUserDirectory

User home directories (/Users).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDocumentationDirectory

Documentation.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDocumentDirectory

Document directory.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSCoreServiceDirectory

Location of core services (System/Library/CoreServices).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDesktopDirectory

Location of user’s desktop directory.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSCachesDirectory

Location of discardable cache files (Library/Caches).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSApplicationSupportDirectory

Location of application support files (Library/Application Support).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSDownloadsDirectory

Location of the user’s downloads directory.

The NSDownloadsDirectory flag will only produce a path only when the NSUserDomainMask is provided.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSAllApplicationsDirectory

All directories where applications can occur.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSAllLibrariesDirectory

All directories where resources can occur.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

Availability
Declared In
NSPathUtilities.h

NSSearchPathDomainMask

Search path domain constants specifying base locations for the NSSearchPathDirectory type.

enum {
   NSUserDomainMask = 1,
   NSLocalDomainMask = 2,
   NSNetworkDomainMask = 4,
   NSSystemDomainMask = 8,
   NSAllDomainsMask = 0x0ffff,
};
typedef NSUInteger NSSearchPathDomainMask;
Constants
NSUserDomainMask

The user’s home directory—the place to install user’s personal items (~).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSLocalDomainMask

Local to the current machine—the place to install items available to everyone on this machine.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSNetworkDomainMask

Publicly available location in the local area network—the place to install items available on the network (/Network).

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSSystemDomainMask

Provided by Apple — can’t be modified (/System) .

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

NSAllDomainsMask

All domains.

Includes all of the above and future items.

Available in iPhone OS 2.0 and later.

Declared in NSPathUtilities.h.

Availability
Declared In
NSPathUtilities.h

NSSocketNativeHandle

Type for the platform-specific native socket handle.

typedef int NSSocketNativeHandle;
Availability
Declared In
NSPort.h

NSStringEncoding

Type representing string-encoding values.

typedef NSUInteger NSStringEncoding;
Discussion

See String Encodings for a list of values.

Availability
Declared In
NSString.h

NSSwappedDouble

Opaque structure containing endian-independent double value.

typedef struct {
   unsigned long long v;
} NSSwappedDouble;
Discussion

The fields of an NSSwappedDouble are private.

Availability
Declared In
NSByteOrder.h

NSSwappedFloat

Opaque type containing an endian-independent float value.

typedef struct {
   unsigned long v;
} NSSwappedFloat;
Discussion

The fields of an NSSwappedFloat are private.

Availability
Declared In
NSByteOrder.h

NSTimeInterval

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
Declared In
NSDate.h

NSUncaughtExceptionHandler

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.

Availability
Declared In
NSException.h

NSUInteger

Used to describe an unsigned integer.

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef unsigned long NSUInteger;
#else
typedef unsigned int NSUInteger;
#endif
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
Declared In
NSObjCRuntime.h

NSZone

Used to identify and manage memory zones.

typedef struct _NSZone NSZone;
Availability
Declared In
NSZone.h

Last updated: 2009-08-20

Did this document help you? Yes It's good, but... Not helpful...