Foundation Data Types Reference
| Framework | Foundation/Foundation.h |
| Declared in | NSByteOrder.h NSDate.h NSDecimal.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
NSComparator
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 iOS 4.0 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 iOS 2.0 and later.
Declared In
NSDecimal.hNSHashTableOptions
Specifies a bitfield used to configure the behavior of elements in an instance of NSHashTable.
typedef NSUInteger NSHashTableOptions
Availability
- Available in iOS 6.0 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 iOS 2.0 and later.
Declared In
NSObjCRuntime.hNSMapTableOptions
Specifies a bitfield used to configure the behavior of elements in an instance of NSMapTable.
typedef NSUInteger NSMapTableOptions
Availability
- Available in iOS 6.0 and later.
Declared In
NSMapTable.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 iOS 2.0 and later.
Declared In
NSRange.hNSRangePointer
Type indicating a parameter is a pointer to an NSRange structure.
typedef NSRange *NSRangePointer;
Availability
- Available in iOS 2.0 and later.
Declared In
NSRange.hNSSocketNativeHandle
Type for the platform-specific native socket handle.
typedef int NSSocketNativeHandle;
Availability
- Available in iOS 2.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 iOS 2.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 iOS 2.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 iOS 2.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 iOS 2.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 iOS 2.0 and later.
Declared In
NSObjCRuntime.hNSZone
Used to identify and manage memory zones.
typedef struct _NSZone NSZone;
Availability
- Available in iOS 2.0 and later.
Declared In
NSZone.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-17)