Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.5 and later. |
Declared in | NSPointerFunctions.h |
Companion guides |
An instance of NSPointerFunctions
defines callout functions appropriate for managing a pointer reference held somewhere else.
The functions specified by an instance of NSPointerFunctions
are separated into two clusters—those that define “personality” such as “object” or "C-string”, and those that describe memory management issues such as a memory deallocation function. There are constants for common personalities and memory manager selections (see “Memory and Personality Options”).
NSHashTable
, NSMapTable
, and NSPointerArray
use an NSPointerFunctions
object to define the acquisition and retention behavior for the pointers they manage. Note, however, that not all combinations of personality and memory management behavior are valid for these collections. The pointer collection objects copy the NSPointerFunctions
object on input and output, so you cannot usefully subclass NSPointerFunctions
.
hashFunction
property
isEqualFunction
property
sizeFunction
property
descriptionFunction
property
acquireFunction
property
relinquishFunction
property
usesStrongWriteBarrier
property
usesWeakReadAndWriteBarriers
property
For more about Objective-C properties, see “Properties” in The Objective-C 2.0 Programming Language.
The function used to acquire memory.
@property void *(*acquireFunction)(const void *src, NSUInteger (*size)(const void *item), BOOL shouldCopy)
This specifies the function to use for copy-in operations.
NSPointerFunctions.h
The function used to describe elements.
@property NSString *(*descriptionFunction)(const void *item)
This function is used by description methods for hash and map tables.
NSPointerFunctions.h
The hash function.
@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item))
NSPointerFunctions.h
The function used to compare pointers.
@property BOOL (*isEqualFunction)(const void *item1, const void*item2, NSUInteger (*size)(const void *item))
NSPointerFunctions.h
The function used to relinquish memory.
@property void (*relinquishFunction)(const void *item, NSUInteger (*size)(const void *item))
This specifies the function to use when an item is removed from a table or pointer array.
NSPointerFunctions.h
The function used to determine the size of pointers.
@property NSUInteger (*sizeFunction)(const void *item)
This function is used for copy-in operations (unless the collection has an object personality).
NSPointerFunctions.h
Specifies whether, in a garbage collected environment, pointers should be assigned using a strong write barrier.
@property BOOL usesStrongWriteBarrier
If you use garbage collection, read and write barrier functions must be used when pointers are from memory scanned by the collector.
NSPointerFunctions.h
Specifies whether, in a garbage collected environment, pointers should use weak read and write barriers.
@property BOOL usesWeakReadAndWriteBarriers
If you use garbage collection, read and write barrier functions must be used when pointers are from memory scanned by the collector.
NSPointerFunctions.h
Returns a new NSPointerFunctions
object initialized with the given options.
+ (id)pointerFunctionsWithOptions:(NSPointerFunctionsOptions)options
The options for the new NSPointerFunctions
object.
A new NSPointerFunctions
object initialized with the given options.
NSPointerFunctions.h
Returns an NSPointerFunctions
object initialized with the given options.
- (id)initWithOptions:(NSPointerFunctionsOptions)options
The options for the new NSPointerFunctions
object.
The receiver, initialized with the given options.
NSPointerFunctions.h
Defines the memory and personality options for an NSPointerFunctions
object.
typedef NSUInteger NSPointerFunctionsOptions;
For values, see “Memory and Personality Options.”
NSPointerFunctions.h
Specify memory and personality options for an NSPointerFunctions
object.
enum { NSPointerFunctionsStrongMemory = (0 << 0), NSPointerFunctionsZeroingWeakMemory = (1 << 0), NSPointerFunctionsOpaqueMemory = (2 << 0), NSPointerFunctionsMallocMemory = (3 << 0), NSPointerFunctionsMachVirtualMemory = (4 << 0), NSPointerFunctionsObjectPersonality = (0 << 8), NSPointerFunctionsOpaquePersonality = (1 << 8), NSPointerFunctionsObjectPointerPersonality = (2 << 8), NSPointerFunctionsCStringPersonality = (3 << 8), NSPointerFunctionsStructPersonality = (4 << 8), NSPointerFunctionsIntegerPersonality = (5 << 8), NSPointerFunctionsCopyIn = (1 << 16), };
NSPointerFunctionsStrongMemory
Use strong write-barriers to backing store; use garbage-collected memory on copy-in.
This is the default memory value.
As a special case, if you do not use garbage collection and specify this value in conjunction with NSPointerFunctionsObjectPersonality
then the NSPointerFunctions
object uses retain
and release
.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsZeroingWeakMemory
Use weak read and write barriers; use garbage-collected memory on copyIn.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsOpaqueMemory
Take no action when pointers are deleted.
This is essentially a no-op relinquish function; the acquire function is only used for copy-in operations. This option is unlikely a to be a good choice for objects.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsMallocMemory
Use free()
on removal, calloc()
on copy in.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsMachVirtualMemory
Use Mach memory.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsObjectPersonality
Use hash
and isEqual
methods for hashing and equality comparisons, use the description
method for a description.
This is the default personality value.
As a special case, if you do not use garbage collection and specify this value in conjunction with NSPointerFunctionsStrongMemory
then the NSPointerFunctions
object uses retain
and release
.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsOpaquePersonality
Use shifted pointer for the hash value and direct comparison to determine equality.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsObjectPointerPersonality
Use shifted pointer for the hash value and direct comparison to determine equality; use the description
method for a description.
As a special case, if you do not use garbage collection and specify this value in conjunction with NSPointerFunctionsStrongMemory
then the NSPointerFunctions
object uses retain
and release
.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsCStringPersonality
Use a string hash and strcmp
; C-string '%s
' style description.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsStructPersonality
Use a memory hash and memcmp
(using a size function that you must set—see sizeFunction
).
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsIntegerPersonality
Use unshifted value as hash and equality.
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
NSPointerFunctionsCopyIn
Use the memory acquire function to allocate and copy items on input (see acquireFunction
).
Available in Mac OS X v10.5 and later.
Declared in NSPointerFunctions.h
.
Memory options are mutually exclusive and personality options are mutually exclusive.
NSPointerFunctions.h
© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)