Framework | Foundation/Foundation.h |
Declared in | NSBundle.h NSByteOrder.h NSDecimal.h NSException.h NSGeometry.h NSHFSFileTypes.h NSHashTable.h NSJavaSetup.h NSMapTable.h NSObjCRuntime.h NSObject.h NSPathUtilities.h NSRange.h NSZone.h |
This chapter describes the functions and function-like macros defined in the Foundation Framework.
For additional information about Assertions, see Assertions and Logging.
NSAssert
NSAssert1
NSAssert2
NSAssert3
NSAssert4
NSAssert5
NSCAssert
NSCAssert1
NSCAssert2
NSCAssert3
NSCAssert4
NSCAssert5
NSCParameterAssert
NSParameterAssert
For additional information on generating strings files see Strings Files in Internationalization Programming Topics.
NSLocalizedString
NSLocalizedStringFromTable
NSLocalizedStringFromTableInBundle
NSLocalizedStringWithDefaultValue
NSConvertHostDoubleToSwapped
NSConvertHostFloatToSwapped
NSConvertSwappedDoubleToHost
NSConvertSwappedFloatToHost
NSHostByteOrder
NSSwapBigDoubleToHost
NSSwapBigFloatToHost
NSSwapBigIntToHost
NSSwapBigLongLongToHost
NSSwapBigLongToHost
NSSwapBigShortToHost
NSSwapDouble
NSSwapFloat
NSSwapHostDoubleToBig
NSSwapHostDoubleToLittle
NSSwapHostFloatToBig
NSSwapHostFloatToLittle
NSSwapHostIntToBig
NSSwapHostIntToLittle
NSSwapHostLongLongToBig
NSSwapHostLongLongToLittle
NSSwapHostLongToBig
NSSwapHostLongToLittle
NSSwapHostShortToBig
NSSwapHostShortToLittle
NSSwapInt
NSSwapLittleDoubleToHost
NSSwapLittleFloatToHost
NSSwapLittleIntToHost
NSSwapLittleLongLongToHost
NSSwapLittleLongToHost
NSSwapLittleShortToHost
NSSwapLong
NSSwapLongLong
NSSwapShort
You can also use the class NSDecimalNumber
for decimal arithmetic.
NSDecimalAdd
NSDecimalCompact
NSDecimalCompare
NSDecimalCopy
NSDecimalDivide
NSDecimalIsNotANumber
NSDecimalMultiply
NSDecimalMultiplyByPowerOf10
NSDecimalNormalize
NSDecimalPower
NSDecimalRound
NSDecimalString
NSDecimalSubtract
You can find the following macros implemented in NSException.h
. Exception Programming Topics for Cocoa discusses these macros and gives examples of their usage. These macros are useful for code that needs to run on versions of the system prior to Mac OS X v10.3 For later versions of the operating system, you should use the Objective-C compiler directives @try
, @catch
, @throw
, and @finally
; for information about these directives, see Exception Handling in The Objective-C 2.0 Programming Language.
NSJavaBundleCleanup
NSJavaBundleSetup
NSJavaClassesForBundle
NSJavaClassesFromPath
NSJavaNeedsToLoadClasses
NSJavaNeedsVirtualMachine
NSJavaObjectNamedInPath
NSJavaProvidesClasses
NSJavaSetup
NSJavaSetupVirtualMachine
NSAllHashTableObjects
NSCompareHashTables
NSCopyHashTableWithZone
NSCountHashTable
NSCreateHashTable
NSCreateHashTableWithZone
NSEndHashTableEnumeration
NSEnumerateHashTable
NSFreeHashTable
NSHashGet
NSHashInsert
NSHashInsertIfAbsent
NSHashInsertKnownAbsent
NSHashRemove
NSNextHashEnumeratorItem
NSResetHashTable
NSStringFromHashTable
NSAllMapTableKeys
NSAllMapTableValues
NSCompareMapTables
NSCopyMapTableWithZone
NSCountMapTable
NSCreateMapTable
NSCreateMapTableWithZone
NSEndMapTableEnumeration
NSEnumerateMapTable
NSFreeMapTable
NSMapGet
NSMapInsert
NSMapInsertIfAbsent
NSMapInsertKnownAbsent
NSMapMember
NSMapRemove
NSNextMapEnumeratorPair
NSResetMapTable
NSStringFromMapTable
NSAllocateObject
NSCopyObject
NSDeallocateObject
NSDecrementExtraRefCountWasZero
NSExtraRefCount
NSIncrementExtraRefCount
NSShouldRetainWithZone
NSGetSizeAndAlignment
NSClassFromString
NSStringFromClass
NSSelectorFromString
NSStringFromSelector
NSStringFromProtocol
NSProtocolFromString
NSFullUserName
NSHomeDirectory
NSHomeDirectoryForUser
NSOpenStepRootDirectory
NSSearchPathForDirectoriesInDomains
NSTemporaryDirectory
NSUserName
NSEqualRanges
NSIntersectionRange
NSLocationInRange
NSMakeRange
NSMaxRange
NSRangeFromString
NSStringFromRange
NSUnionRange
NSContainsRect
NSDivideRect
NSEqualRects
NSIsEmptyRect
NSHeight
NSInsetRect
NSIntegralRect
NSIntersectionRect
NSIntersectsRect
NSMakeRect
NSMaxX
NSMaxY
NSMidX
NSMidY
NSMinX
NSMinY
NSMouseInRect
NSOffsetRect
NSPointInRect
NSRectFromString
NSStringFromRect
NSRectFromCGRect
NSRectToCGRect
NSUnionRect
NSWidth
Whether there’s an uncaught exception handler function, any uncaught exceptions cause the program to terminate, unless the exception is raised during the posting of a notification.
NSDefaultMallocZone
NSAllocateCollectable
NSReallocateCollectable
NSMakeCollectable
NSAllocateMemoryPages
NSCopyMemoryPages
NSDeallocateMemoryPages
NSLogPageSize
NSPageSize
NSRealMemoryAvailable
NSRoundDownToMultipleOfPageSize
NSRoundUpToMultipleOfPageSize
NSCreateZone
NSRecycleZone
NSSetZoneName
NSZoneCalloc
NSZoneFree
NSZoneFromPointer
NSZoneMalloc
NSZoneName
NSZoneRealloc
Returns all of the elements in the specified hash table.
NSArray * NSAllHashTableObjects ( NSHashTable *table );
An array object containing all the elements of table.
This function should be called only when the table elements are objects, not when they’re any other data type.
NSHashTable.h
Returns all of the keys in the specified map table.
NSArray * NSAllMapTableKeys ( NSMapTable *table );
An array object containing all the keys in table. This function should be called only when table keys are objects, not when they’re any other type of pointer.
NSMapTable.h
Returns all of the values in the specified table.
NSArray * NSAllMapTableValues ( NSMapTable *table );
An array object containing all the values in table. This function should be called only when table values are objects, not when they’re any other type of pointer.
NSMapTable.h
Allocates collectable memory.
void *__strong NSAllocateCollectable ( NSUInteger size, NSUInteger options );
The number of bytes of memory to allocate.
0
or NSScannedOption
: A value of 0
allocates nonscanned memory; a value of NSScannedOption
allocates scanned memory.
A pointer to the allocated memory, or NULL
if the function is unable to allocate the requested memory.
NSZone.h
Allocates a new block of memory.
void * NSAllocateMemoryPages ( NSUInteger bytes );
Allocates the integral number of pages whose total size is closest to, but not less than, byteCount. The allocated pages are guaranteed to be filled with zeros. If the allocation fails, raises NSInvalidArgumentException
.
NSZone.h
Creates and returns a new instance of a given class.
id NSAllocateObject ( Class aClass, NSUInteger extraBytes, NSZone *zone );
The class of which to create an instance.
The number of extra bytes required for indexed instance variables (this value is typically 0
).
The zone in which to create the new instance (pass NULL
to specify the default zone).
A new instance of aClass or nil
if an instance could not be created.
NSObject.h
Generates an assertion if a given condition is false.
#define NSAssert(condition, desc)
An expression that evaluates to YES
or NO
.
An NSString
object that contains an error message describing the failure condition.
The NSAssert
macro evaluates the condition and serves as a front end to the assertion handler.
Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception. If condition evaluates to NO
, the macro invokes handleFailureInMethod:object:file:lineNumber:description:
on the assertion handler for the current thread, passing desc as the description string.
This macro should be used only within Objective-C methods.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined.
NSException.h
Generates an assertion if a given condition is false.
#define NSAssert1(condition, desc, arg1)
An expression that evaluates to YES
or NO
.
An NSString
object that contains a printf
-style string containing an error message describing the failure condition and a placeholder for a single argument.
An argument to be inserted, in place, into desc.
The NSAssert1
macro evaluates the condition and serves as a front end to the assertion handler.
Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception. If condition evaluates to NO
, the macro invokes handleFailureInMethod:object:file:lineNumber:description:
on the assertion handler for the current thread, passing desc as the description string and arg1 as a substitution variable.
This macro should be used only within Objective-C methods.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined.
NSLog
NSLogv
NSAssert
NSAssert2
NSAssert3
NSAssert4
NSAssert5
NSCAssert
NSCParameterAssert
NSParameterAssert
NSException.h
Generates an assertion if a given condition is false.
#define NSAssert2(condition, desc, arg1, arg2)
An expression that evaluates to YES
or NO
.
An NSString
object that contains a printf
-style string containing an error message describing the failure condition and placeholders for two arguments.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
The NSAssert2
macro evaluates the condition and serves as a front end to the assertion handler.
Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception. If condition evaluates to NO
, the macro invokes handleFailureInMethod:object:file:lineNumber:description:
on the assertion handler for the current thread, passing desc as the description string and arg1 and arg2 as substitution variables.
This macro should be used only within Objective-C methods.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined.
NSLog
NSLogv
NSAssert
NSAssert1
NSAssert3
NSAssert4
NSAssert5
NSCAssert
NSCParameterAssert
NSParameterAssert
NSException.h
Generates an assertion if a given condition is false.
#define NSAssert3(condition, desc, arg1, arg2, arg3)
An expression that evaluates to YES
or NO
.
An NSString
object that contains a printf
-style string containing an error message describing the failure condition and placeholders for three arguments.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
The NSAssert3
macro evaluates the condition and serves as a front end to the assertion handler.
Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception. If condition evaluates to NO
, the macro invokes handleFailureInMethod:object:file:lineNumber:description:
on the assertion handler for the current thread, passing desc as the description string and arg1, arg2, and arg3 as substitution variables.
This macro should be used only within Objective-C methods.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined.
NSLog
NSLogv
NSAssert
NSAssert1
NSAssert2
NSAssert4
NSAssert5
NSCAssert
NSCParameterAssert
NSParameterAssert
NSException.h
Generates an assertion if a given condition is false.
#define NSAssert4(condition, desc, arg1, arg2, arg3, arg4)
An expression that evaluates to YES
or NO
.
An NSString
object that contains a printf
-style string containing an error message describing the failure condition and placeholders for four arguments.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
The NSAssert4
macro evaluates the condition and serves as a front end to the assertion handler.
Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception. If condition evaluates to NO
, the macro invokes handleFailureInMethod:object:file:lineNumber:description:
on the assertion handler for the current thread, passing desc as the description string and arg1, arg2, arg3, and arg4 as substitution variables.
This macro should be used only within Objective-C methods.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined.
NSLog
NSLogv
NSAssert
NSAssert1
NSAssert2
NSAssert3
NSAssert5
NSCAssert
NSCParameterAssert
NSParameterAssert
NSException.h
Generates an assertion if a given condition is false.
#define NSAssert5(condition, desc, arg1, arg2, arg3, arg4, arg5)
An expression that evaluates to YES
or NO
.
An NSString
object that contains a printf
-style string containing an error message describing the failure condition and placeholders for five arguments.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
An argument to be inserted, in place, into desc.
The NSAssert5
macro evaluates the condition and serves as a front end to the assertion handler.
Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes the method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception. If condition evaluates to NO
, the macro invokes handleFailureInMethod:object:file:lineNumber:description:
on the assertion handler for the current thread, passing desc as the description string and arg1, arg2, arg3, arg4, and arg5 as substitution variables.
This macro should be used only within Objective-C methods.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined.
NSLog
NSLogv
NSAssert
NSAssert1
NSAssert2
NSAssert3
NSAssert4
NSCAssert
NSCParameterAssert
NSParameterAssert
NSException.h
Generates an assertion if the given condition is false.
NSCAssert(condition, NSString *description)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
The NSCAssert
macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions. NSCAssert
takes no arguments other than the condition and format string.
The condition must be an expression that evaluates to true or false. description is a printf-style format string that describes the failure condition.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSException.h
NSCAssert1
is one of a series of macros that generate assertions if the given condition is false.
NSCAssert1(condition, NSString *description, arg1)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
The NSCAssert1
macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions.
The condition expression must evaluate to true or false. description is a printf-style format string that describes the failure condition. arg1 is an argument to be inserted, in place, into the description.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSLog
NSLogv
NSCAssert
NSCAssert2
NSCAssert3
NSCAssert4
NSCAssert5
NSCParameterAssert
NSParameterAssert
NSException.h
NSCAssert2
is one of a series of macros that generate assertions if the given condition is false.
NSCAssert2(condition, NSString *description, arg1, arg2)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
The NSCAssert2
macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions.
The condition expression must evaluate to true or false. description is a printf-style format string that describes the failure condition. Each argn is an argument to be inserted, in place, into the description.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSLog
NSLogv
NSCAssert
NSCAssert1
NSCAssert3
NSCAssert4
NSCAssert5
NSCParameterAssert
NSParameterAssert
NSException.h
NSCAssert3
is one of a series of macros that generate assertions if the given condition is false.
NSCAssert3(condition, NSString *description, arg1, arg2, arg3)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
The NSCAssert3
macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions.
The condition expression must evaluate to true or false. description is a printf-style format string that describes the failure condition. Each argn is an argument to be inserted, in place, into the description.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSLog
NSLogv
NSCAssert
NSCAssert1
NSCAssert2
NSCAssert4
NSCAssert5
NSCParameterAssert
NSParameterAssert
NSException.h
NSCAssert4
is one of a series of macros that generate assertions if the given condition is false.
NSCAssert4(condition, NSString *description, arg1, arg2, arg3, arg4)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
The NSCAssert4
macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions.
The condition expression must evaluate to true or false. description is a printf-style format string that describes the failure condition. Each argn is an argument to be inserted, in place, into the description.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSLog
NSLogv
NSCAssert
NSCAssert1
NSCAssert2
NSCAssert3
NSCAssert5
NSCParameterAssert
NSParameterAssert
NSException.h
NSCAssert5
is one of a series of macros that generate assertions if the given condition is false.
NSCAssert5(condition, NSString *description, arg1, arg2, arg3, arg4, arg5)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
The NSCAssert5
macro evaluates the condition and serves as a front end to the assertion handler. This macro should be used only within C functions.
The condition expression must evaluate to true or false. description is a printf-style format string that describes the failure condition. Each argn is an argument to be inserted, in place, into the description.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSLog
NSLogv
NSCAssert
NSCAssert1
NSCAssert2
NSCAssert3
NSCAssert4
NSCParameterAssert
NSParameterAssert
NSException.h
Obtains a class by name.
Class NSClassFromString ( NSString *aClassName );
The name of a class.
The class object named by aClassName, or nil
if no class by that name is currently loaded. If aClassName is nil
, returns nil
.
NSObjCRuntime.h
Returns a Boolean value that indicates whether the elements of two hash tables are equal.
BOOL NSCompareHashTables ( NSHashTable *table1, NSHashTable *table2 );
YES
if the two hash tables are equal—that is, if each element of table1 is in table2 and the two tables are the same size, otherwise NO
.
NSHashTable.h
Compares the elements of two map tables for equality.
BOOL NSCompareMapTables ( NSMapTable *table1, NSMapTable *table2 );
YES
if each key of table1 is in table2, and the two tables are the same size, otherwise NO
.
Note that this function does not compare values, only keys.
NSMapTable.h
Returns a Boolean value that indicates whether one rectangle completely encloses another.
BOOL NSContainsRect ( NSRect aRect, NSRect bRect );
YES
if aRect completely encloses bRect. For this condition to be true, bRect cannot be empty, and must not extend beyond aRect in any direction.
NSGeometry.h
Performs a type conversion.
NSSwappedDouble NSConvertHostDoubleToSwapped ( double x );
Converts the double value in x to a value whose bytes can be swapped. This function does not actually swap the bytes of x. You should not need to call this function directly.
NSByteOrder.h
Performs a type conversion.
NSSwappedFloat NSConvertHostFloatToSwapped ( float x );
Converts the float value in x to a value whose bytes can be swapped. This function does not actually swap the bytes of x. You should not need to call this function directly.
NSByteOrder.h
Performs a type conversion.
double NSConvertSwappedDoubleToHost ( NSSwappedDouble x );
Converts the value in x to a double value. This function does not actually swap the bytes of x. You should not need to call this function directly.
NSByteOrder.h
Performs a type conversion.
float NSConvertSwappedFloatToHost ( NSSwappedFloat x );
Converts the value in x to a float value. This function does not actually swap the bytes of x. You should not need to call this function directly.
NSByteOrder.h
Performs a shallow copy of the specified hash table.
NSHashTable * NSCopyHashTableWithZone ( NSHashTable *table, NSZone *zone );
A pointer to a new copy of table, created in zone and containing pointers to the data elements of table.
If zone is NULL
, the new table is created in the default zone.
The new table adopts the callback functions of table and calls the hash
and retain
callback functions as appropriate when inserting elements into the new table.
NSHashTable.h
Performs a shallow copy of the specified map table.
NSMapTable * NSCopyMapTableWithZone ( NSMapTable *table, NSZone *zone );
A pointer to a new copy of table, created in zone and containing pointers to the keys and values of table.
If zone is NULL
, the new table is created in the default zone.
The new table adopts the callback functions of table and calls the hash
and retain
callback functions as appropriate when inserting elements into the new table.
NSCreateMapTable
NSCreateMapTableWithZone
NSMapTableKeyCallBacks
(structure)NSMapTableValueCallBacks
(structure)NSMapTable.h
Copies a block of memory.
void NSCopyMemoryPages ( const void *source, void *dest, NSUInteger bytes );
Copies (or copies on write) byteCount bytes from source to destination.
NSZone.h
Creates an exact copy of an object.
id NSCopyObject ( id object, NSUInteger extraBytes, NSZone *zone );
The object to copy.
The number of extra bytes required for indexed instance variables (this value is typically 0
).
The zone in which to create the new instance (pass NULL
to specify the default zone).
A new object that’s an exact copy of anObject, or nil
if object is nil
or if object could not be copied.
NSObject.h
Returns the number of elements in a hash table.
NSUInteger NSCountHashTable ( NSHashTable *table );
The number of elements currently in table.
NSHashTable.h
Returns the number of elements in a map table.
NSUInteger NSCountMapTable ( NSMapTable *table );
A reference to a map table structure.
The number of key-value pairs currently in table.
NSMapTable.h
Evaluates the specified parameter.
NSCParameterAssert(condition)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
This macro validates a parameter for a C function. Simply provide the parameter as the condition argument. The macro evaluates the parameter and, if the parameter evaluates to false, logs an error message that includes the parameter and then raises an exception.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All macros return void
.
NSException.h
Creates and returns a new hash table.
NSHashTable * NSCreateHashTable ( NSHashTableCallBacks callBacks, NSUInteger capacity );
A pointer to an NSHashTable created in the default zone.
The table’s size is dependent on (but generally not equal to) capacity. If capacity is 0, a small hash table is created. The NSHashTableCallBacks
structure callBacks has five pointers to functions, with the following defaults: pointer hashing, if hash
is NULL
; pointer equality, if isEqual
is NULL
; no callback upon adding an element, if retain
is NULL
; no callback upon removing an element, if release
is NULL
; and a function returning a pointer’s hexadecimal value as a string, if describe
is NULL
. The hashing function must be defined such that if two data elements are equal, as defined by the comparison function, the values produced by hashing on these elements must also be equal. Also, data elements must remain invariant if the value of the hashing function depends on them; for example, if the hashing function operates directly on the characters of a string, that string can’t change.
NSHashTable.h
Creates a new hash table in a given zone.
NSHashTable * NSCreateHashTableWithZone ( NSHashTableCallBacks callBacks, NSUInteger capacity, NSZone *zone );
A pointer to a new hash table created in the specified zone. If zone is NULL
, the hash table is created in the default zone.
The table’s size is dependent on (but generally not equal to) capacity. If capacity is 0, a small hash table is created. The NSHashTableCallBacks
structure callBacks has five pointers to functions, with the following defaults: pointer hashing, if hash
is NULL
; pointer equality, if isEqual
is NULL
; no callback upon adding an element, if retain
is NULL
; no callback upon removing an element, if release
is NULL
; and a function returning a pointer’s hexadecimal value as a string, if describe
is NULL
. The hashing function must be defined such that if two data elements are equal, as defined by the comparison function, the values produced by hashing on these elements must also be equal. Also, data elements must remain invariant if the value of the hashing function depends on them; for example, if the hashing function operates directly on the characters of a string, that string can’t change.
NSHashTable.h
Creates a new map table in the default zone.
NSMapTable * NSCreateMapTable ( NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, NSUInteger capacity );
Creates and returns a pointer to an NSMapTable
structure in the default zone; the table’s size is dependent on (but generally not equal to) capacity. If capacity is 0, a small map table is created. The NSMapTableKeyCallBacks
arguments are structures that are very similar to the callback structure used by NSCreateHashTable
—they have the same defaults as documented for that function.
NSMapTable.h
Creates a new map table in the specified zone.
NSMapTable * NSCreateMapTableWithZone ( NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, NSUInteger capacity, NSZone *zone );
A new map table in allocated in zone. If zone is NULL
, the hash table is created in the default zone.
The table’s size is dependent on (but generally not equal to) capacity. If capacity is 0, a small map table is created. The NSMapTableKeyCallBacks
arguments are structures that are very similar to the callback structure used by NSCreateHashTable
; in fact, they have the same defaults as documented for that function.
NSMapTable.h
Creates a new zone.
NSZone * NSCreateZone ( NSUInteger startSize, NSUInteger granularity, BOOL canFree );
A pointer to a new zone of startSize bytes, which will grow and shrink by granularity bytes. If canFree is 0, the allocator will never free memory, and malloc
will be fast. Returns NULL
if a new zone could not be created.
NSZone.h
Deallocates the specified block of memory.
void NSDeallocateMemoryPages ( void *ptr, NSUInteger bytes );
This function deallocates memory that was allocated with NSAllocateMemoryPages
.
NSZone.h
Destroys an existing object.
void NSDeallocateObject ( id object );
An object.
This function deallocates object, which must have been allocated using NSAllocateObject
.
NSObject.h
Adds two decimal values.
NSCalculationError NSDecimalAdd ( NSDecimal *result, const NSDecimal *leftOperand, const NSDecimal *rightOperand, NSRoundingMode roundingMode );
Adds leftOperand to rightOperand and stores the sum in result.
An NSDecimal can represent a number with up to 38 significant digits. If a number is more precise than that, it must be rounded off. roundingMode determines how to round it off. There are four possible rounding modes:
NSRoundDown | Round return values down. |
NSRoundUp | Round return values up. |
NSRoundPlain | Round to the closest possible return value; when caught halfway between two positive numbers, round up; when caught between two negative numbers, round down. |
NSRoundBankers | Round to the closest possible return value; when halfway between two possibilities, return the possibility whose last digit is even. |
The return value indicates whether any machine limitations were encountered in the addition. If none were encountered, the function returns NSCalculationNoError
. Otherwise it may return one of the following values: NSCalculationLossOfPrecision
, NSCalculationOverflow
or NSCalculationUnderflow
. For descriptions of all these error conditions, see exceptionDuringOperation:error:leftOperand:rightOperand:
in NSDecimalNumberBehaviors.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Compacts the decimal structure for efficiency.
void NSDecimalCompact ( NSDecimal *number );
Formats number so that calculations using it will take up as little memory as possible. All the NSDecimal...
arithmetic functions expect compact NSDecimal arguments.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Compares two decimal values.
NSComparisonResult NSDecimalCompare ( const NSDecimal *leftOperand, const NSDecimal *rightOperand );
NSOrderedDescending
if leftOperand is bigger than rightOperand; NSOrderedAscending
if rightOperand is bigger than leftOperand; or NSOrderedSame
if the two operands are equal.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Copies the value of a decimal number.
void NSDecimalCopy ( NSDecimal *destination, const NSDecimal *source );
Copies the value in source to destination.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Divides one decimal value by another.
NSCalculationError NSDecimalDivide ( NSDecimal *result, const NSDecimal *leftOperand, const NSDecimal *rightOperand, NSRoundingMode roundingMode );
Divides leftOperand by rightOperand and stores the quotient, possibly rounded off according to roundingMode, in result. If rightOperand is 0, returns NSDivideByZero
.
For explanations of the possible return values and rounding modes, see NSDecimalAdd
.
Note that repeating decimals or numbers with a mantissa larger than 38 digits cannot be represented precisely.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Returns a Boolean that indicates whether a given decimal contains a valid number.
BOOL NSDecimalIsNotANumber ( const NSDecimal *dcm );
YES
if the value in decimal represents a valid number, otherwise NO
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Multiplies two decimal numbers together.
NSCalculationError NSDecimalMultiply ( NSDecimal *result, const NSDecimal *leftOperand, const NSDecimal *rightOperand, NSRoundingMode roundingMode );
Multiplies rightOperand by leftOperand and stores the product, possibly rounded off according to roundingMode, in result.
For explanations of the possible return values and rounding modes, see NSDecimalAdd
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Multiplies a decimal by the specified power of 10.
NSCalculationError NSDecimalMultiplyByPowerOf10 ( NSDecimal *result, const NSDecimal *number, short power, NSRoundingMode roundingMode );
Multiplies number by power of 10 and stores the product, possibly rounded off according to roundingMode, in result.
For explanations of the possible return values and rounding modes, see NSDecimalAdd
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Normalizes the internal format of two decimal numbers to simplify later operations.
NSCalculationError NSDecimalNormalize ( NSDecimal *number1, NSDecimal *number2, NSRoundingMode roundingMode );
An NSDecimal is represented in memory as a mantissa and an exponent, expressing the value mantissa x 10exponent. A number can have many NSDecimal representations; for example, the following table lists several valid NSDecimal representations for the number 100:
Mantissa |
Exponent |
---|---|
100 |
0 |
10 |
1 |
1 |
2 |
Format number1 and number2 so that they have equal exponents. This format makes addition and subtraction very convenient. Both NSDecimalAdd
and NSDecimalSubtract
call NSDecimalNormalize
. You may want to use it if you write more complicated addition or subtraction routines.
For explanations of the possible return values, see NSDecimalAdd
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Raises the decimal value to the specified power.
NSCalculationError NSDecimalPower ( NSDecimal *result, const NSDecimal *number, NSUInteger power, NSRoundingMode roundingMode );
Raises number to power, possibly rounding off according to roundingMode, and stores the resulting value in result.
For explanations of the possible return values and rounding modes, see NSDecimalAdd
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Rounds off the decimal value.
void NSDecimalRound ( NSDecimal *result, const NSDecimal *number, NSInteger scale, NSRoundingMode roundingMode );
Rounds number off according to the parameters scale and roundingMode and stores the result in result.
The scale value specifies the number of digits result can have after its decimal point. roundingMode specifies the way that number is rounded off. There are four possible values for roundingMode: NSRoundDown
, NSRoundUp
, NSRoundPlain
, and NSRoundBankers
. For thorough discussions of scale and roundingMode, see NSDecimalNumberBehaviors
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Returns a string representation of the decimal value.
NSString * NSDecimalString ( const NSDecimal *dcm, id locale );
Returns a string representation of decimal. locale determines the format of the decimal separator.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Subtracts one decimal value from another.
NSCalculationError NSDecimalSubtract ( NSDecimal *result, const NSDecimal *leftOperand, const NSDecimal *rightOperand, NSRoundingMode roundingMode );
Subtracts rightOperand from leftOperand and stores the difference, possibly rounded off according to roundingMode, in result.
For explanations of the possible return values and rounding modes, see NSDecimalAdd
.
For more information, see Number and Value Programming Topics for Cocoa.
NSDecimal.h
Decrements the specified object’s reference count.
BOOL NSDecrementExtraRefCountWasZero ( id object );
An object.
NO
if anObject had an extra reference count, or YES
if anObject didn’t have an extra reference count—indicating that the object should be deallocated (with dealloc
).
Decrements the “extra reference” count of anObject. Newly created objects have only one actual reference, so that a single release message results in the object being deallocated. Extra references are those beyond the single original reference and are usually created by sending the object a retain message. Your code should generally not use these functions unless it is overriding the retain
or release
methods.
NSObject.h
Returns the default zone.
NSZone * NSDefaultMallocZone (void);
The default zone, which is created automatically at startup.
This zone is used by the standard C function malloc
.
NSZone.h
Divides a rectangle into two new rectangles.
void NSDivideRect ( NSRect inRect, NSRect *slice, NSRect *rem, CGFloat amount, NSRectEdge edge );
Creates two rectangles—slice and rem—from inRect, by dividing inRect with a line that’s parallel to the side of inRect specified by edge. The size of slice is determined by amount, which specifies the distance from edge.
slice and rem must not be NULL
.
For more information, see NSRectEdge
.
NSGeometry.h
Used when finished with an enumerator.
void NSEndHashTableEnumeration ( NSHashEnumerator *enumerator );
This function should be called when you have finished using the enumeration struct enumerator.
NSHashTable.h
Used when finished with an enumerator.
void NSEndMapTableEnumeration ( NSMapEnumerator *enumerator );
This function should be called when you have finished using the enumeration struct enumerator.
NSMapTable.h
Creates an enumerator for the specified hash table.
NSHashEnumerator NSEnumerateHashTable ( NSHashTable *table );
An NSHashEnumerator structure that will cause successive elements of table to be returned each time this enumerator is passed to NSNextHashEnumeratorItem
.
NSHashTable.h
Creates an enumerator for the specified map table.
NSMapEnumerator NSEnumerateMapTable ( NSMapTable *table );
A reference to a map table structure.
An NSMapEnumerator
structure that will cause successive key-value pairs of table to be visited each time this enumerator is passed to NSNextMapEnumeratorPair
.
NSMapTable.h
Returns a Boolean value that indicates whether two points are equal.
BOOL NSEqualPoints ( NSPoint aPoint, NSPoint bPoint );
YES
if the two points aPoint and bPoint are identical, otherwise NO
.
NSGeometry.h
Returns a Boolean value that indicates whether two given ranges are equal.
BOOL NSEqualRanges ( NSRange range1, NSRange range2 );
YES
if range1 and range2 have the same locations and lengths.
NSRange.h
Returns a Boolean value that indicates whether the two rectangles are equal.
BOOL NSEqualRects ( NSRect aRect, NSRect bRect );
YES
if aRect and bRect are identical, otherwise NO
.
NSGeometry.h
Returns a Boolean that indicates whether two size values are equal.
BOOL NSEqualSizes ( NSSize aSize, NSSize bSize );
YES
if aSize and bSize are identical, otherwise NO
.
NSGeometry.h
Returns the specified object’s reference count.
NSUInteger NSExtraRefCount ( id object );
An object.
The current reference count of object.
This function is used in conjunction with NSIncrementExtraRefCount
and NSDecrementExtraRefCountWasZero
in situations where you need to override an object’s retain
and release
methods.
NSObject.h
Returns a string encoding a file type code.
NSString * NSFileTypeForHFSTypeCode ( OSType hfsFileTypeCode );
An HFS file type code.
A string that encodes hfsFileTypeCode.
For more information, see HFS File Types.
NSHFSFileTypes.h
Deletes the specified hash table.
void NSFreeHashTable ( NSHashTable *table );
Releases each element of the specified hash table and frees the table itself.
NSHashTable.h
Deletes the specified map table.
void NSFreeMapTable ( NSMapTable *table );
A reference to a map table structure.
Releases each key and value of the specified map table and frees the table itself.
NSMapTable.h
Returns a string containing the full name of the current user.
NSString * NSFullUserName (void);
A string containing the full name of the current user.
NSPathUtilities.h
Obtains the actual size and the aligned size of an encoded type.
const char * NSGetSizeAndAlignment ( const char *typePtr, NSUInteger *sizep, NSUInteger *alignp );
Obtains the actual size and the aligned size of the first data type represented by typePtr and returns a pointer to the position of the next data type in typePtr. You can specify NULL
for either sizep or alignp to ignore the corresponding information.
The value returned in alignp is the aligned size of the data type; for example, on some platforms, the aligned size of a char
might be 2 bytes while the actual physical size is 1 byte.
NSObjCRuntime.h
Returns the top-level error handler.
NSUncaughtExceptionHandler * NSGetUncaughtExceptionHandler (void);
A pointer to the top-level error-handling function where you can perform last-minute logging before the program terminates.
NSException.h
Returns an element of the hash table.
void * NSHashGet ( NSHashTable *table, const void *pointer );
The pointer in the table that matches pointer (as defined by the isEqual
callback function). If there is no matching element, returns NULL
.
NSHashTable.h
Adds an element to the specified hash table.
void NSHashInsert ( NSHashTable *table, const void *pointer );
Inserts pointer, which must not be NULL
, into table. If pointer matches an item already in the table, the previous pointer is released using the release
callback function that was specified when the table was created.
NSHashTable.h
Adds an element to the specified hash table only if the table does not already contain the element.
void * NSHashInsertIfAbsent ( NSHashTable *table, const void *pointer );
If pointer matches an item already in table, returns the preexisting pointer; otherwise, pointer is added to the table and returns NULL
.
You must not specify NULL
for pointer.
NSHashTable.h
Adds an element to the specified hash table.
void NSHashInsertKnownAbsent ( NSHashTable *table, const void *pointer );
Inserts pointer, which must not be NULL
, into table. Unlike NSHashInsert
, this function raises NSInvalidArgumentException
if table already includes an element that matches pointer.
NSHashTable.h
Removes an element from the specified hash table.
void NSHashRemove ( NSHashTable *table, const void *pointer );
If pointer matches an item already in table, this function releases the preexisting item.
NSHashTable.h
Returns the height of a given rectangle.
CGFloat NSHeight ( NSRect aRect );
The height of aRect.
NSGeometry.h
Returns a file type code.
OSType NSHFSTypeCodeFromFileType ( NSString *fileTypeString );
A string of the sort encoded by NSFileTypeForHFSTypeCode()
.
The HFS file type code corresponding to fileTypeString, or 0
if it cannot be found.
For more information, see HFS File Types.
NSHFSFileTypes.h
Returns a string encoding a file type.
NSString * NSHFSTypeOfFile ( NSString *fullFilePath );
The full absolute path of a file.
A string that encodes fullFilePath‘s HFS file type, or nil
if the operation was not successful
For more information, see HFS File Types.
NSHFSFileTypes.h
Returns the path to the current user’s home directory.
NSString * NSHomeDirectory (void);
The path to the current user’s home directory.
For more information on file-system utilities, see Low-Level File Management Programming Topics.
NSPathUtilities.h
Returns the path to a given user’s home directory.
NSString * NSHomeDirectoryForUser ( NSString *userName );
The name of a user.
The path to the home directory for the user specified by userName.
For more information on file system utilities, see Low-Level File Management Programming Topics.
NSPathUtilities.h
Returns the endian format.
long NSHostByteOrder (void);
The endian format, either NS_LittleEndian
or NS_BigEndian
.
NSByteOrder.h
Increments the specified object’s reference count.
void NSIncrementExtraRefCount ( id object );
An object.
This function increments the “extra reference” count of object. Newly created objects have only one actual reference, so that a single release message results in the object being deallocated. Extra references are those beyond the single original reference and are usually created by sending the object a retain message. Your code should generally not use these functions unless it is overriding the retain or release methods.
NSObject.h
Insets a rectangle by a specified amount.
NSRect NSInsetRect ( NSRect aRect, CGFloat dX, CGFloat dY );
A copy of aRect, altered by moving the two sides that are parallel to the y axis inward by dX, and the two sides parallel to the x axis inwards by dY.
NSGeometry.h
Adjusts the sides of a rectangle to integer values.
NSRect NSIntegralRect ( NSRect aRect );
A copy of aRect, expanded outward just enough to ensure that none of its four defining values (x, y, width, and height) have fractional parts. If the width or height of aRect is 0
or negative, this function returns a rectangle with origin at (0.0, 0.0) and with zero width and height.
NSGeometry.h
Returns the intersection of the specified ranges.
NSRange NSIntersectionRange ( NSRange range1, NSRange range2 );
A range describing the intersection of range1 and range2—that is, a range containing the indices that exist in both ranges.
If the returned range’s length field is 0, then the two ranges don’t intersect, and the value of the location field is undefined.
NSRange.h
Calculates the intersection of two rectangles.
NSRect NSIntersectionRect ( NSRect aRect, NSRect bRect );
The graphic intersection of aRect and bRect. If the two rectangles don’t overlap, the returned rectangle has its origin at (0.0, 0.0) and zero width and height (including situations where the intersection is a point or a line segment).
NSGeometry.h
Returns a Boolean value that indicates whether two rectangles intersect.
BOOL NSIntersectsRect ( NSRect aRect, NSRect bRect );
YES
if aRect intersects bRect, otherwise NO
. Returns NO
if either aRect or bRect has a width or height that is 0.
NSGeometry.h
Returns a Boolean value that indicates whether a given rectangle is empty.
BOOL NSIsEmptyRect ( NSRect aRect );
YES
if aRect encloses no area at all—that is, if its width or height is 0 or negative, otherwise NO
.
NSGeometry.h
This function has been deprecated.
void NSJavaBundleCleanup ( NSBundle *bundle, NSDictionary *plist );
NSJavaSetup.h
This function has been deprecated.
id NSJavaBundleSetup ( NSBundle *bundle, NSDictionary *plist );
NSJavaSetup.h
Loads the Java classes located in the specified bundle.
NSArray * NSJavaClassesForBundle ( NSBundle *bundle, BOOL usesyscl, id *vm );
Loads and returns the Java classes in the specified bundle. If the Java virtual machine is not loaded, load it first. A reference to the Java virtual machine is returned in the vm parameter. You can pass nil
for the vm parameter if you do not want this information. Pass NO
for usesyscl if you want to use a new instance of the class loader to load the classes; otherwise, the system can reuse an existing instance of the class loader. If you pass NO
for usesyscl, the new class loader will be released when you are done with it; otherwise, the class loader will be cached for use next time.
NSJavaSetup.h
Loads the Java classes located at the specified path.
NSArray * NSJavaClassesFromPath ( NSArray *path, NSArray *wanted, BOOL usesyscl, id *vm );
Loads and returns the Java classes in the specified bundle. If the Java virtual machine is not loaded, load it first. A reference to the Java virtual machine is returned in the vm parameter. You can pass nil
for the vm parameter if you do not want this information. Pass an array of names of classes to load in the wanted parameter. If you pass nil
for the wanted parameter, all classes at the specified path will be loaded. Pass NO
for usesyscl if you want to use a new instance of the class loader to load the classes; otherwise, the system can reuse an existing instance of the class loader. If you pass NO
for usesyscl, the new class loader will be released when you are done with it; otherwise, the class loader will be cached for use next time.
NSJavaSetup.h
Returns a Boolean value that indicates whether a virtual machine is needed or if Java classes are provided.
BOOL NSJavaNeedsToLoadClasses ( NSDictionary *plist );
Returns YES
if a virtual machine is needed or if a virtual machine already exists and there’s an indication that Java classes are provided.
NSJavaSetup.h
Returns a Boolean value that indicates whether a Java virtual machine is required.
BOOL NSJavaNeedsVirtualMachine ( NSDictionary *plist );
Returns YES
if plist contains a key saying that it requires Java.
NSJavaSetup.h
Creates an instance of the named class using the class loader previously specified at the given path.
id NSJavaObjectNamedInPath ( NSString *name, NSArray *path );
Returns a new instance of the class name. The class loader must be already be set up for the specified path (you can do this using a function such as NSJavaClassesFromPath
).
NSJavaSetup.h
Returns a Boolean value that indicates whether Java classes are provided.
BOOL NSJavaProvidesClasses ( NSDictionary *plist );
Returns YES
if plist contains an NSJavaPath
key.
NSJavaSetup.h
Loads the Java virtual machine with specified parameters.
id NSJavaSetup ( NSDictionary *plist );
Part of the Java-to-Objective-C bridge. You normally shouldn’t use it yourself.
You can pass nil
for the plist dictionary, in which case the Java virtual machine will not be loaded, so you should probably just use NSJavaSetupVirtualMachine
instead. The plist dictionary may contain the following key-value pairs.
NSJavaRoot
—An NSString indicating the root of the location where the application’s classes are.
NSJavaPath
—An NSArray of NSStrings, each string containing one component of a class path whose components will be prepended by NSJavaRoot
if they are not absolute locations.
NSJavaUserPath
—An NSString indicating another segment of the class path so that the application developer can customize where the class loader should search for classes. When searching for classes, this path is searched after the application’s class path so that one cannot replace the classes used by the application.
NSJavaLibraryPath
—An NSArray of NSStrings, each string containing one component of a path to search for dynamic shared libraries needed by Java wrappers.
NSJavaClasses
—An NSArray of NSStrings, each string containing the name of one class that the VM should load so that their associated frameworks will be loaded.
NSJavaSetup.h
Sets up the Java virtual machine.
id NSJavaSetupVirtualMachine (void);
Sets up and returns a reference to the Java virtual machine.
NSJavaSetup.h
Returns a localized version of a string.
NSString *NSLocalizedString(NSString *key, NSString *comment)
The result of invoking localizedStringForKey:value:table:
on the main bundle and a nil
table.
You can specify Unicode characters in key using \\Uxxxx
—see the -u
option for for the genstrings
utility.
For more information, see NSBundle
.
In Mac OS X v10.4 and earlier, to ensure correct parsing by the genstrings
utility, the key parameter must not contain any high-ASCII characters.
NSBundle.h
Returns a localized version of a string.
NSString *NSLocalizedStringFromTable(NSString *key, NSString *tableName, NSString *comment)
The result of invoking localizedStringForKey:value:table:
on the main bundle, passing it the specified key and tableName.
You can specify Unicode characters in key using \\Uxxxx
—see the -u
option for for the genstrings
utility.
For more information, see NSBundle
.
In Mac OS X v10.4 and earlier, to ensure correct parsing by the genstrings
utility, the key parameter must not contain any high-ASCII characters.
NSBundle.h
Returns a localized version of a string.
NSString *NSLocalizedStringFromTableInBundle(NSString *key, NSString *tableName, NSBundle *bundle, NSString *comment)
The result of invoking localizedStringForKey:value:table:
on bundle, passing it the specified key and tableName.
You can specify Unicode characters in key using \\Uxxxx
—see the -u
option for for the genstrings
utility.
For more information, see NSBundle
.
In Mac OS X v10.4 and earlier, to ensure correct parsing by the genstrings
utility, the key parameter must not contain any high-ASCII characters.
NSBundle.h
Returns a localized version of a string.
NSString NSLocalizedStringWithDefaultValue(NSString *key, NSString *tableName, NSBundle *bundle, NSString *value, NSString *comment)
The result of invoking localizedStringForKey:value:table:
on bundle, passing it the specified key, value, and tableName.
You can specify Unicode characters in key using \\Uxxxx
—see the -u
option for for the genstrings
utility.
If you use genstrings
to parse your code for localizable strings, you can use this method to specify an initial value that is different from key
.
For more information, see NSBundle
.
In Mac OS X v10.4 and earlier, to ensure correct parsing by the genstrings
utility, the key parameter must not contain any high-ASCII characters.
NSBundle.h
Returns a Boolean value that indicates whether a specified position is in a given range.
BOOL NSLocationInRange ( NSUInteger loc, NSRange range );
YES
if loc lies within range—that is, if it’s greater than or equal to range.location
and less than range.location
plus range.length
.
NSRange.h
Logs an error message to the Apple System Log facility.
void NSLog ( NSString *format, ... );
Simply calls NSLogv
, passing it a variable number of arguments.
NSObjCRuntime.h
Returns the binary log of the page size.
NSUInteger NSLogPageSize (void);
The binary log of the page size.
NSZone.h
Logs an error message to the Apple System Log facility.
void NSLogv ( NSString *format, va_list args );
Logs an error message to the Apple System Log facility (see man 3 asl
). If the STDERR_FILENO
file descriptor has been redirected away from the default or is going to a tty, it will also be written there. If you want to direct output elsewhere, you need to use a custom logging facility.
The message consists of a timestamp and the process ID prefixed to the string you pass in. You compose this string with a format string, format, and one or more arguments to be inserted into the string. The format specification allowed by these functions is that which is understood by NSString
’s formatting capabilities (which is not necessarily the set of format escapes and flags understood by printf
). The supported format specifiers are described in String Format Specifiers. A final hard return is added to the error message if one is not present in the format.
In general, you should use the NSLog
function instead of calling this function directly. If you do use this function directly, you must have prepared the variable argument list in the args argument by calling the standard C macro va_start
. Upon completion, you must similarly call the standard C macro va_end
for this list.
Output from NSLogv
is serialized, in that only one thread in a process can be doing the writing/logging described above at a time. All attempts at writing/logging a message complete before the next thread can begin its attempts.
The effects of NSLogv
are not serialized with subsystems other than those discussed above (such as the standard I/O package) and do not produce side effects on those subsystems (such as causing buffered output to be flushed, which may be undesirable).
NSObjCRuntime.h
Makes a newly allocated Core Foundation object eligible for collection.
NS_INLINE id NSMakeCollectable(CFTypeRef cf) { return cf ? (id)CFMakeCollectable(cf) : nil; }
This function is a wrapper for CFMakeCollectable
, but its return type is id
—avoiding the need for casting when using Cocoa objects.
This function may be useful when returning Core Foundation objects in code that must support both garbage-collected and non-garbage-collected environments, as illustrated in the following example.
- (CFDateRef)foo { |
CFDateRef aCFDate; |
// ... |
return [NSMakeCollectable(aCFDate) autorelease]; |
} |
CFTypeRef style objects are garbage collected, yet only sometime after the last CFRelease
is performed. Particularly for fully-bridged CFTypeRef objects such as CFStrings and collections (such as CFDictionary), you must call either CFMakeCollectable
or the more type safe NSMakeCollectable
, preferably right upon allocation.
NSZone.h
Creates a new NSPoint
from the specified values.
NSPoint NSMakePoint ( CGFloat x, CGFloat y );
An NSPoint
having the coordinates x and y.
NSGeometry.h
Creates a new NSRange from the specified values.
NSRange NSMakeRange ( NSUInteger loc, NSUInteger len );
An NSRange
with location location and length length.
NSRange.h
Creates a new NSRect
from the specified values.
NSRect NSMakeRect ( CGFloat x, CGFloat y, CGFloat w, CGFloat h );
An NSRect
having the specified origin of [x, y] and size of [w, h].
NSGeometry.h
Returns a new NSSize
from the specified values.
NSSize NSMakeSize ( CGFloat w, CGFloat h );
An NSSize
having the specified width and height.
NSGeometry.h
Returns a map table value for the specified key.
void * NSMapGet ( NSMapTable *table, const void *key );
The value that table maps to key, or NULL
if table doesn’t contain key.
NSMapTable.h
Inserts a key-value pair into the specified table.
void NSMapInsert ( NSMapTable *table, const void *key, const void *value );
Inserts key and value into table. If key matches a key already in table, value is retained and the previous value is released, using the retain
and release
callback functions that were specified when the table was created. Raises NSInvalidArgumentException
if key is equal to the notAKeyMarker
field of the table’s NSMapTableKeyCallBacks
structure.
NSMapTable.h
Inserts a key-value pair into the specified table.
void * NSMapInsertIfAbsent ( NSMapTable *table, const void *key, const void *value );
If key matches a key already in table, the preexisting key; otherwise, key and value are added to table and returns NULL
.
Raises NSInvalidArgumentException
if key is equal to the notAKeyMarker
field of the table’s NSMapTableKeyCallBacks
structure.
NSMapTable.h
Inserts a key-value pair into the specified table if the pair had not been previously added.
void NSMapInsertKnownAbsent ( NSMapTable *table, const void *key, const void *value );
Inserts key (which must not be notAKeyMarker
) and value into table. Unlike NSMapInsert
, this function raises NSInvalidArgumentException
if table already includes a key that matches key.
key is compared with notAKeyMarker
using pointer comparison; if key is identical to notAKeyMarker
, raises NSInvalidArgumentException
.
NSMapTable.h
Indicates whether a given table contains a given key.
BOOL NSMapMember ( NSMapTable *table, const void *key, void **originalKey, void **value );
YES
if table contains a key equal to key, otherwise NO
.
If table contains a key equal to key, originalKey is set to key, and value is set to the value that table maps to key.
NSMapTable.h
Removes a key and corresponding value from the specified table.
void NSMapRemove ( NSMapTable *table, const void *key );
If key matches a key already in table, this function releases the preexisting key and its corresponding value.
NSMapTable.h
Returns the number 1 greater than the maximum value within the range.
NSUInteger NSMaxRange ( NSRange range );
range.location
+ range.length
—in other words, the number 1 greater than the maximum value within the range.
NSRange.h
Returns the largest x coordinate of a given rectangle.
CGFloat NSMaxX ( NSRect aRect );
The largest x coordinate value within aRect.
NSGeometry.h
Returns the largest y coordinate of a given rectangle.
CGFloat NSMaxY ( NSRect aRect );
The largest y coordinate value within aRect.
NSGeometry.h
Returns the x coordinate of a given rectangle’s midpoint.
CGFloat NSMidX ( NSRect aRect );
Returns the x coordinate of the center of aRect.
NSGeometry.h
Returns the y coordinate of a given rectangle’s midpoint.
CGFloat NSMidY ( NSRect aRect );
The y coordinate of aRect’s center point.
NSGeometry.h
Returns the smallest x coordinate of a given rectangle.
CGFloat NSMinX ( NSRect aRect );
The smallest x coordinate value within aRect.
NSGeometry.h
Returns the smallest y coordinate of a given rectangle.
CGFloat NSMinY ( NSRect aRect );
The smallest y coordinate value within aRect.
NSGeometry.h
Returns a Boolean value that indicates whether the point is in the specified rectangle.
BOOL NSMouseInRect ( NSPoint aPoint, NSRect aRect, BOOL flipped );
YES
if the hot spot of the cursor lies inside a given rectangle, otherwise NO
.
This method assumes an unscaled and unrotated coordinate system. Specify YES
for isFlipped if the underlying view uses a flipped coordinate system.
Point-in-rectangle functions generally assume that the bottom edge of a rectangle is outside of the rectangle boundaries, while the upper edge is inside the boundaries. This method views aRect from the point of view of the user—that is, this method always treats the bottom edge of the rectangle as the one closest to the bottom edge of the user’s screen. By making this adjustment, this function ensures consistent mouse-detection behavior from the user’s perspective.
NSGeometry.h
Returns the next hash-table element in the enumeration.
void * NSNextHashEnumeratorItem ( NSHashEnumerator *enumerator );
The next element in the table that enumerator is associated with, or NULL
if enumerator has already iterated over all the elements.
NSHashTable.h
Returns a Boolean value that indicates whether the next map-table pair in the enumeration are set.
BOOL NSNextMapEnumeratorPair ( NSMapEnumerator *enumerator, void **key, void **value );
NO
if enumerator has already iterated over all the elements in the table that enumerator is associated with; otherwise, sets key and value to match the next key-value pair in the table and returns YES
.
NSMapTable.h
Offsets the rectangle by the specified amount.
NSRect NSOffsetRect ( NSRect aRect, CGFloat dX, CGFloat dY );
A copy of aRect, with its location shifted by dX along the x axis and by dY along the y axis.
NSGeometry.h
Returns the root directory of the user’s system.
NSString * NSOpenStepRootDirectory (void);
A string identifying the root directory of the user’s system.
For more information on file system utilities, see Low-Level File Management Programming Topics.
NSPathUtilities.h
Returns the number of bytes in a page.
NSUInteger NSPageSize (void);
The number of bytes in a page.
NSZone.h
Validates the specified parameter.
NSParameterAssert(condition)
Assertions evaluate a condition and, if the condition evaluates to false, call the assertion handler for the current thread, passing it a format string and a variable number of arguments. Each thread has its own assertion handler, which is an object of class NSAssertionHandler
. When invoked, an assertion handler prints an error message that includes method and class names (or the function name). It then raises an NSInternalInconsistencyException
exception.
This macro validates a parameter for an Objective-C method. Simply provide the parameter as the condition argument. The macro evaluates the parameter and, if it is false, it logs an error message that includes the parameter and then raises an exception.
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS
is defined. All assertion macros return void.
NSException.h
Returns an NSPoint
typecast from a CGPoint
.
NSPoint NSPointFromCGPoint(CGPoint cgpoint) { return (*(NSPoint *)&(cgpoint)); }
An NSPoint
typecast from a CGPoint
.
NSGeometry.h
Returns a point from a text-based representation.
NSPoint NSPointFromString ( NSString *aString );
A string of the form “{x, y}”.
If aString is of the form “{x, y}” an NSPoint
structure that uses x and y as the x and y coordinates, in that order.
If aString only contains a single number, it is used as the x coordinate. If aString does not contain any numbers, returns an NSPoint
object whose x and y coordinates are both 0.
NSGeometry.h
Returns a Boolean value that indicates whether a given point is in a given rectangle.
BOOL NSPointInRect ( NSPoint aPoint, NSRect aRect );
YES
if aPoint is located within the rectangle represented by aRect, otherwise NO
.
Point-in-rectangle functions generally assume that the “upper” and “left” edges of a rectangle are inside the rectangle boundaries, while the “lower” and “right” edges are outside the boundaries. This method treats the “upper” and “left” edges of the rectangle as the ones containing the origin of the rectangle.
The meanings of “upper” and “lower” (and “left” and “right”) are relative to the current coordinate system and the location of the rectangle. For a rectangle of positive height located in positive x and y coordinates:
In the default Mac OS X desktop coordinate system—where the origin is at the bottom left—the rectangle edge closest to the bottom of the screen is the “upper” edge (and is considered inside the rectangle).
On iPhone OS and in a flipped coordinate system on Mac OS X desktop—where the origin is at the top left—the rectangle edge closest to the bottom of the screen is the “lower” edge (and is considered outside the rectangle).
NSGeometry.h
Returns a CGPoint
typecast from an NSPoint
.
CGPoint NSPointToCGPoint(NSPoint nspoint) { union _ {NSPoint ns; CGPoint cg;}; return ((union _ *)&nspoint)->cg; }
A CGPoint
typecast from an NSPoint
.
NSGeometry.h
Returns a the protocol with a given name.
Protocol *NSProtocolFromString ( NSString *namestr );
The name of a protocol.
The protocol object named by namestr, or nil
if no protocol by that name is currently loaded. If namestr is nil
, returns nil
.
NSObjCRuntime.h
Returns a range from a text-based representation.
NSRange NSRangeFromString ( NSString *aString );
Scans aString for two integers which are used as the location and length values, in that order, to create an NSRange
struct. If aString only contains a single integer, it is used as the location value. If aString does not contain any integers, this function returns an NSRange
struct whose location and length values are both 0.
NSRange.h
Reallocates collectable memory.
void *__strong NSReallocateCollectable ( void *ptr, NSUInteger size, NSUInteger options );
Changes the size of the block of memory pointed to by ptr to size bytes. It may allocate new memory to replace the old, in which case it moves the contents of the old memory block to the new block, up to a maximum of size bytes.
options can be 0
or NSScannedOption
: A value of 0
allocates nonscanned memory; a value of NSScannedOption
allocates scanned memory.
This function returns NULL
if it’s unable to allocate the requested memory.
NSZone.h
Returns information about the user’s system.
NSUInteger NSRealMemoryAvailable (void);
The number of bytes available in RAM.
NSZone.h
Returns an NSRect
typecast from a CGRect
.
NSRect NSRectFromCGRect(CGRect cgrect) { return (*(NSRect *)&(cgrect)); }
An NSRect
typecast from a CGRect
.
NSGeometry.h
Returns a rectangle from a text-based representation.
NSRect NSRectFromString ( NSString *aString );
Scans aString for four numbers which are used as the x and y coordinates and the width and height, in that order, to create an NSPoint object. If aString does not contain four numbers, those numbers that were scanned are used, and 0 is used for the remaining values. If aString does not contain any numbers, this function returns an NSRect object with a rectangle whose origin is (0, 0) and width and height are both 0.
NSGeometry.h
Returns a CGRect
typecast from an NSRect
.
CGRect NSRectToCGRect(NSRect nsrect) { return (*(CGRect *)&(nsrect)); }
A CGRect
typecast from an NSRect
.
NSGeometry.h
Frees memory in a zone.
void NSRecycleZone ( NSZone *zone );
Frees zone after adding any of its pointers still in use to the default zone. (This strategy prevents retained objects from being inadvertently destroyed.)
NSZone.h
Deletes the elements of the specified hash table.
void NSResetHashTable ( NSHashTable *table );
Releases each element but doesn’t deallocate table. This function is useful for preserving the capacity of table.
NSHashTable.h
Deletes the elements of the specified map table.
void NSResetMapTable ( NSMapTable *table );
A reference to a map table structure.
Releases each key and value but doesn’t deallocate table. This method is useful for preserving the capacity of table.
NSMapTable.h
Returns the specified number of bytes rounded down to a multiple of the page size.
NSUInteger NSRoundDownToMultipleOfPageSize ( NSUInteger bytes );
In bytes, the multiple of the page size that is closest to, but not greater than, byteCount (that is, the number of bytes rounded down to a multiple of the page size).
NSZone.h
Returns the specified number of bytes rounded up to a multiple of the page size.
NSUInteger NSRoundUpToMultipleOfPageSize ( NSUInteger bytes );
In bytes, the multiple of the page size that is closest to, but not less than, byteCount (that is, the number of bytes rounded up to a multiple of the page size).
NSZone.h
Creates a list of directory search paths.
NSArray * NSSearchPathForDirectoriesInDomains ( NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde );
Creates a list of path strings for the specified directories in the specified domains. The list is in the order in which you should search the directories. If expandTilde is YES
, tildes are expanded as described in stringByExpandingTildeInPath
.
For more information on file system utilities, see Locating Directories on the System.
NSPathUtilities.h
Returns the selector with a given name.
SEL NSSelectorFromString ( NSString *aSelectorName );
A string of any length, with any characters, that represents the name of a selector.
The selector named by aSelectorName. If aSelectorName is nil
, or cannot be converted to UTF-8 (this should be only due to insufficient memory), returns (SEL)0
.
To make a selector, NSSelectorFromString
passes a UTF-8 encoded character representation of aSelectorName to sel_registerName
and returns the value returned by that function. Note, therefore, that if the selector does not exist it is registered and the newly-registered selector is returned.
Recall that a colon (“:”) is part of a method name; setHeight
is not the same as setHeight:
. For more about methods names, see The Language in The Objective-C 2.0 Programming Language.
NSObjCRuntime.h
Changes the top-level error handler.
void NSSetUncaughtExceptionHandler ( NSUncaughtExceptionHandler * );
Sets the top-level error-handling function where you can perform last-minute logging before the program terminates.
NSGetUncaughtExceptionHandler
reportException:
(NSApplication
)NSException.h
Sets the name of the specified zone.
void NSSetZoneName ( NSZone *zone, NSString *name );
Sets the name of zone to name, which can aid in debugging.
NSZone.h
Indicates whether an object should be retained.
BOOL NSShouldRetainWithZone ( id anObject, NSZone *requestedZone );
An object.
A memory zone.
Returns YES
if requestedZone is NULL
, the default zone, or the zone in which anObject was allocated; otherwise NO
.
This function is typically called from inside an NSObject
’s copyWithZone:
, when deciding whether to retain anObject as opposed to making a copy of it.
NSObject.h
Returns an NSSize
typecast from a CGSize
.
NSSize NSSizeFromCGSize(CGSize cgsize) { return (*(NSSize *)&(cgsize)); }
An NSSize
typecast from a CGSize
.
NSGeometry.h
Returns an NSSize
from a text-based representation.
NSSize NSSizeFromString ( NSString *aString );
Scans aString for two numbers which are used as the width and height, in that order, to create an NSSize
struct. If aString only contains a single number, it is used as the width. The aString argument should be formatted like the output of NSStringFromSize, for example, @"{10,20}"
. If aString does not contain any numbers, this function returns an NSSize
struct whose width and height are both 0
.
NSGeometry.h
Returns a CGSize
typecast from an NSSize
.
CGSize NSSizeToCGSize(NSSize nssize) { return (*(CGSize *)&(nssize)); }
A CGSize
typecast from an NSSize
.
NSGeometry.h
Returns the name of a class as a string.
NSString * NSStringFromClass ( Class aClass );
A class.
A string containing the name of aClass. If aClass is nil
, returns nil
.
NSObjCRuntime.h
Returns a string describing the hash table’s contents.
NSString * NSStringFromHashTable ( NSHashTable *table );
A string describing table’s contents.
The function iterates over the elements of table, and for each one appends the string returned by the describe
callback function. If NULL
was specified for the callback function, the hexadecimal value of each pointer is added to the string.
NSHashTable.h
Returns a string describing the map table’s contents.
NSString * NSStringFromMapTable ( NSMapTable *table );
A reference to a map table structure.
A string describing the map table’s contents.
The function iterates over the key-value pairs of table and for each one appends the string “a = b;\n”, where a and b are the key and value strings returned by the corresponding describe
callback functions. If NULL
was specified for the callback function, a and b are the key and value pointers, expressed as hexadecimal numbers.
NSMapTable.h
Returns a string representation of a point.
NSString * NSStringFromPoint ( NSPoint aPoint );
A point structure.
A string of the form “{a, b}”, where a and b are the x and y coordinates of aPoint.
NSGeometry.h
Returns the name of a protocol as a string.
NSString * NSStringFromProtocol ( Protocol *proto );
A protocol.
A string containing the name of proto.
NSObjCRuntime.h
Returns a string representation of a range.
NSString * NSStringFromRange ( NSRange range );
A string of the form “{a, b}”, where a and b are non-negative integers representing aRange.
NSRange.h
Returns a string representation of a rectangle.
NSString * NSStringFromRect ( NSRect aRect );
Returns a string of the form “{{a, b}, {c, d}}”, where a, b, c, and d are the x and y coordinates and the width and height, respectively, of aRect.
NSGeometry.h
Returns a string representation of a given selector.
NSString *NSStringFromSelector ( SEL *aSelector );
A selector.
A string representation of aSelector.
NSObjCRuntime.h
Returns a string representation of a size.
NSString * NSStringFromSize ( NSSize aSize );
A string of the form “{a, b}”, where a and b are the width and height, respectively, of aSize.
NSGeometry.h
A utility for swapping the bytes of a number.
double NSSwapBigDoubleToHost ( NSSwappedDouble x );
Converts the big-endian value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapDouble
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
float NSSwapBigFloatToHost ( NSSwappedFloat x );
Converts the big-endian value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapFloat
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned int NSSwapBigIntToHost ( unsigned int x );
Converts the big-endian value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapInt
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long long NSSwapBigLongLongToHost ( unsigned long long x );
Converts the big-endian value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapLongLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long NSSwapBigLongToHost ( unsigned long x );
Converts the big-endian value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned short NSSwapBigShortToHost ( unsigned short x );
Converts the big-endian value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapShort
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
NSSwappedDouble NSSwapDouble ( NSSwappedDouble x );
Swaps the bytes of x and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of x are numbered from 1 to 8, this function swaps bytes 1 and 8, bytes 2 and 7, bytes 3 and 6, and bytes 4 and 5.
NSByteOrder.h
A utility for swapping the bytes of a number.
NSSwappedFloat NSSwapFloat ( NSSwappedFloat x );
Swaps the bytes of x and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of x are numbered from 1 to 4, this function swaps bytes 1 and 4, and bytes 2 and 3.
NSByteOrder.h
A utility for swapping the bytes of a number.
NSSwappedDouble NSSwapHostDoubleToBig ( double x );
Converts the value in x, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapDouble
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
NSSwappedDouble NSSwapHostDoubleToLittle ( double x );
Converts the value in x, specified in the current endian format, to little-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapDouble
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
NSSwappedFloat NSSwapHostFloatToBig ( float x );
Converts the value in x, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapFloat
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
NSSwappedFloat NSSwapHostFloatToLittle ( float x );
Converts the value in x, specified in the current endian format, to little-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapFloat
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned int NSSwapHostIntToBig ( unsigned int x );
Converts the value in x, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapInt
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned int NSSwapHostIntToLittle ( unsigned int x );
Converts the value in x, specified in the current endian format, to little-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapInt
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long long NSSwapHostLongLongToBig ( unsigned long long x );
Converts the value in x, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapLongLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long long NSSwapHostLongLongToLittle ( unsigned long long x );
Converts the value in x, specified in the current endian format, to little-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapLongLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long NSSwapHostLongToBig ( unsigned long x );
Converts the value in x, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long NSSwapHostLongToLittle ( unsigned long x );
Converts the value in x, specified in the current endian format, to little-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned short NSSwapHostShortToBig ( unsigned short x );
Converts the value in x, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapShort
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned short NSSwapHostShortToLittle ( unsigned short x );
Converts the value in x, specified in the current endian format, to little-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapShort
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned int NSSwapInt ( unsigned int inv );
Swaps the bytes of inv and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of inv are numbered from 1 to 4, this function swaps bytes 1 and 4, and bytes 2 and 3.
NSByteOrder.h
A utility for swapping the bytes of a number.
double NSSwapLittleDoubleToHost ( NSSwappedDouble x );
Converts the little-endian formatted value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapDouble
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
float NSSwapLittleFloatToHost ( NSSwappedFloat x );
Converts the little-endian formatted value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapFloat
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned int NSSwapLittleIntToHost ( unsigned int x );
Converts the little-endian formatted value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapInt
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long long NSSwapLittleLongLongToHost ( unsigned long long x );
Converts the little-endian formatted value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls NSSwapLongLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long NSSwapLittleLongToHost ( unsigned long x );
Converts the little-endian formatted value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapLong
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned short NSSwapLittleShortToHost ( unsigned short x );
Converts the little-endian formatted value in x to the current endian format and returns the resulting value. If it is necessary to swap the bytes of x, this function calls NSSwapShort
to perform the swap.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long NSSwapLong ( unsigned long inv );
Swaps the bytes of inv and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of inv are numbered from 1 to 4, this function swaps bytes 1 and 4, and bytes 2 and 3.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned long long NSSwapLongLong ( unsigned long long inv );
Swaps the bytes of inv and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of inv are numbered from 1 to 8, this function swaps bytes 1 and 8, bytes 2 and 7, bytes 3 and 6, and bytes 4 and 5.
NSByteOrder.h
A utility for swapping the bytes of a number.
unsigned short NSSwapShort ( unsigned short inv );
Swaps the low-order and high-order bytes of inv and returns the resulting value.
NSByteOrder.h
Returns the path of the temporary directory for the current user.
NSString * NSTemporaryDirectory (void);
A string containing the path of the temporary directory for the current user. If no such directory is currently available, returns nil
.
For more information on file system utilities, see Low-Level File Management Programming Topics.
The temporary directory is determined by confstr
(3) passing the _CS_DARWIN_USER_TEMP_DIR
flag. The erase rules are whatever match that directory.
NSPathUtilities.h
Returns the union of the specified ranges.
NSRange NSUnionRange ( NSRange range1, NSRange range2 );
A range covering all indices in and between range1 and range2. If one range is completely contained in the other, the returned range is equal to the larger range.
NSRange.h
Calculates the union of two rectangles.
NSRect NSUnionRect ( NSRect aRect, NSRect bRect );
Returns the smallest rectangle that completely encloses both aRect and bRect. If one of the rectangles has 0 (or negative) width or height, a copy of the other rectangle is returned; but if both have 0 (or negative) width or height, the returned rectangle has its origin at (0.0, 0.0) and has 0 width and height.
NSGeometry.h
Returns the logon name of the current user.
NSString * NSUserName (void);
The logon name of the current user.
NSPathUtilities.h
Returns the width of the specified rectangle.
CGFloat NSWidth ( NSRect aRect );
The width of aRect.
NSGeometry.h
Allocates memory in a zone.
void * NSZoneCalloc ( NSZone *zone, NSUInteger numElems, NSUInteger byteSize );
Allocates enough memory from zone for numElems elements, each with a size numBytes bytes, and returns a pointer to the allocated memory. The memory is initialized with zeros. This function returns NULL
if it was unable to allocate the requested memory.
NSZone.h
Deallocates a block of memory in the specified zone.
void NSZoneFree ( NSZone *zone, void *ptr );
Returns memory to the zone from which it was allocated. The standard C function free
does the same, but spends time finding which zone the memory belongs to.
NSZone.h
Gets the zone for a given block of memory.
NSZone * NSZoneFromPointer ( void *ptr );
The zone for the block of memory indicated by pointer, or NULL
if the block was not allocated from a zone.
pointer must be one that was returned by a prior call to an allocation function.
NSZone.h
Allocates memory in a zone.
void * NSZoneMalloc ( NSZone *zone, NSUInteger size );
Allocates size bytes in zone and returns a pointer to the allocated memory. This function returns NULL
if it was unable to allocate the requested memory.
NSZone.h
Returns the name of the specified zone.
NSString * NSZoneName ( NSZone *zone );
A string containing the name associated with zone. If zone is nil
, the default zone is used. If no name is associated with zone, the returned string is empty.
NSZone.h
Allocates memory in a zone.
void * NSZoneRealloc ( NSZone *zone, void *ptr, NSUInteger size );
Changes the size of the block of memory pointed to by ptr to size bytes. It may allocate new memory to replace the old, in which case it moves the contents of the old memory block to the new block, up to a maximum of size bytes. ptr may be NULL
. This function returns NULL
if it was unable to allocate the requested memory.
NSZone.h
Marks the start of the exception-handling domain.
NS_DURING
The NS_DURING
macro marks the start of the exception-handling domain for a section of code. (The NS_HANDLER
macro marks the end of the domain.) Within the exception-handling domain you can raise an exception, giving the local exception handler (or lower exception handlers) a chance to handle it.
NSException.h
Marks the end of the local event handler.
NS_ENDHANDLER
The NS_ENDHANDLER
marks the end of a section of code that is a local exception handler. (The NS_HANDLER
macros marks the beginning of this section.) If an exception is raised in the exception handling domain marked off by the NS_DURING
and NS_HANDLER
, the local exception handler (if specified) is given a chance to handle the exception.
NSException.h
Marks the end of the exception-handling domain and the start of the local exception handler.
NS_HANDLER
The NS_HANDLER macro marks end of a section of code that is an exception-handling domain while at the same time marking the beginning of a section of code that is a local exception handler for that domain. (The NS_DURING
macro marks the beginning of the exception-handling domain; the NS_ENDHANDLER
marks the end of the local exception handler.) If an exception is raised in the exception-handling domain, the local exception handler is first given the chance to handle the exception before lower-level handlers are given a chance.
NSException.h
Permits program control to exit from an exception-handling domain with a value of a specified type.
NS_VALUERETURN(val, type)
A value to preserve beyond the exception-handling domain.
The type of the value specified in val
.
The NS_VALUERETURN
macro returns program control to the caller out of the exception-handling domain—that is, a section of code between the NS_DURING
and NS_HANDLER
macros that might raise an exception. The specified value (of the specified type) is returned to the caller. The standard return
statement does not work as expected in the exception-handling domain.
NSException.h
Permits program control to exit from an exception-handling domain.
NS_VOIDRETURN
The NS_VOIDRETURN
macro returns program control to the caller out of the exception-handling domain—that is, a section of code between the NS_DURING
and NS_HANDLER
macros that might raise an exception. The standard return
statement does not work as expected in the exception-handling domain.
NSException.h
© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)