NSPointerFunctions Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.5 and later. |
| Declared in | NSPointerFunctions.h |
| Companion guides |
Overview
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.
Adopted Protocols
Tasks
Creating and Initializing an NSPointerFunctions Object
Personality Functions
-
hashFunctionproperty -
isEqualFunctionproperty -
sizeFunctionproperty -
descriptionFunctionproperty
Memory Configuration
-
acquireFunctionproperty -
relinquishFunctionproperty -
usesStrongWriteBarrierproperty -
usesWeakReadAndWriteBarriersproperty
Properties
acquireFunction
The function used to acquire memory.
Discussion
This specifies the function to use for copy-in operations.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPointerFunctions.hdescriptionFunction
The function used to describe elements.
Discussion
This function is used by description methods for hash and map tables.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.hhashFunction
The hash function.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.hisEqualFunction
The function used to compare pointers.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.hrelinquishFunction
The function used to relinquish memory.
Discussion
This specifies the function to use when an item is removed from a table or pointer array.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPointerFunctions.hsizeFunction
The function used to determine the size of pointers.
Discussion
This function is used for copy-in operations (unless the collection has an object personality).
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.husesStrongWriteBarrier
Specifies whether, in a garbage collected environment, pointers should be assigned using a strong write barrier.
Discussion
If you use garbage collection, read and write barrier functions must be used when pointers are from memory scanned by the collector.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.husesWeakReadAndWriteBarriers
Specifies whether, in a garbage collected environment, pointers should use weak read and write barriers.
Discussion
If you use garbage collection, read and write barrier functions must be used when pointers are from memory scanned by the collector.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPointerFunctions.hClass Methods
pointerFunctionsWithOptions:
Returns a new NSPointerFunctions object initialized with the given options.
Parameters
- options
The options for the new
NSPointerFunctionsobject.
Return Value
A new NSPointerFunctions object initialized with the given options.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.hInstance Methods
initWithOptions:
Returns an NSPointerFunctions object initialized with the given options.
Parameters
- options
The options for the new
NSPointerFunctionsobject.
Return Value
The NSPointerFunctions object, initialized with the given options.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.hConstants
NSPointerFunctionsOptions
Defines the memory and personality options for an NSPointerFunctions object.
typedef NSUInteger NSPointerFunctionsOptions;
Discussion
For values, see “Memory and Personality Options.”
Availability
- Available in OS X v10.5 and later.
Declared In
NSPointerFunctions.hMemory and Personality Options
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),
NSPointerFunctionsWeakMemory = (5UL << 0),
NSPointerFunctionsObjectPersonality = (0 << 8),
NSPointerFunctionsOpaquePersonality = (1 << 8),
NSPointerFunctionsObjectPointerPersonality = (2 << 8),
NSPointerFunctionsCStringPersonality = (3 << 8),
NSPointerFunctionsStructPersonality = (4 << 8),
NSPointerFunctionsIntegerPersonality = (5 << 8),
NSPointerFunctionsCopyIn = (1 << 16),
};
Constants
NSPointerFunctionsStrongMemoryUse 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
NSPointerFunctionsObjectPersonalityorNSPointerFunctionsObjectPointerPersonalitythen theNSPointerFunctionsobject usesretainandrelease.If you do not use garbage collection, and specify this value in conjunction with a valid non-object personality, it is the same as specifying
NSPointerFunctionsMallocMemory.Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsZeroingWeakMemoryUse weak read and write barriers; use garbage-collected memory on copyIn.
If you do not use garbage collection, for object personalities, it will hold a non-retained object pointer.
Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsOpaqueMemoryTake no action when pointers are deleted.
This is usually the preferred memory option for holding arbitrary pointers.
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 OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsMallocMemoryUse
free()on removal,calloc()on copy in.Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsMachVirtualMemoryUse Mach memory.
Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsWeakMemoryUses weak read and write barriers appropriate for ARC or GC. Using NSPointerFunctionsWeakMemory object references will turn to
NULLon last release.Available in OS X v10.8 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsObjectPersonalityUse
hashandisEqualmethods for hashing and equality comparisons, use thedescriptionmethod 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
NSPointerFunctionsStrongMemorythen theNSPointerFunctionsobject usesretainandrelease.Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsOpaquePersonalityUse shifted pointer for the hash value and direct comparison to determine equality.
Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsObjectPointerPersonalityUse shifted pointer for the hash value and direct comparison to determine equality; use the
descriptionmethod for a description.As a special case, if you do not use garbage collection and specify this value in conjunction with
NSPointerFunctionsStrongMemorythen theNSPointerFunctionsobject usesretainandrelease.Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsCStringPersonalityUse a string hash and
strcmp; C-string '%s' style description.Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsStructPersonalityUse a memory hash and
memcmp(using a size function that you must set—seesizeFunction).Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsIntegerPersonalityUse unshifted value as hash and equality.
Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.NSPointerFunctionsCopyInUse the memory acquire function to allocate and copy items on input (see
acquireFunction).Available in OS X v10.5 and later.
Declared in
NSPointerFunctions.h.
Discussion
Memory options are mutually exclusive and personality options are mutually exclusive.
Declared In
NSPointerFunctions.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)