Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.
NSTaggedPointerString - an NSString that stores a small (up to 11 characters, with restrictions) ASCII-subset string inside the pointer instead of allocating an actual object
NSPathStore2 - an NSString specialized for storing filesystem paths
NSSpellingSubstring - implementation detail of NSSpellChecker
NSPinyinString - implementation detail of NSTextCheckingResult
NS*PredicateOperator - implementation details of NSPredicate
NSLocalizableString - used by Interface Builder for localized strings
NSSimpleCString - historical, mostly unused
NSConstantString - historical, used only if compiling with -fno-constant-cfstrings
NSDebugString - used to implement the NSShowNonLocalizedStrings/NSShowNonLocalizableStrings debugging features
_NSStringProxyForContext - implementation detail of NSFormattingContext
__NSVariableWidthString - used by the localization system
__NSLocalizedString - used by the localization system
_NSClStr - an NSString that zeroes its contents with memset_s() when deallocated
Arrays:
__NSArray0 - a singleton empty immutable NSArray, makes @[] and [NSArray array] very efficient
__NSArrayI - an immutable NSArray that stores its contents inline. The most common NSArray type.
__NSArrayI_Transfer - an immutable NSArray that stores its contents out of line. Used for zero-copy initialization in a few places.
__NSSingleObjectArrayI - an immutable NSArray that stores a single object inline. Fits in 16 bytes where a regular __NSArrayI would need 24 since it stores the count.
__NSArrayReversed - acts as a proxy for another NSArray and presents its contents in reverse order
__NSFrozenArrayM - an immutable NSArray sharing its storage with an NSMutableArray that it was -copy'd from (will do a real copy if the original array is mutated)
NSKeyValueArray - uses Key-Value Coding to act as a proxy for a to-many property designated by a key path
_NSCallStackArray - stores a list of addresses for an exception call stack and lazily symbolicates them on access
__NSOrderedSetArrayProxy - acts as a proxy for an NSOrderedSet, allowing -[NSOrderedSet array] to avoid copying
NSXMLChildren - stores the children of an NSXMLElement in a way that allows limited copy-on-write (predates general CoW support)
__NSArrayM - a mutable NSArray backed by an out of line array-deque
__NSCFArray - a CFArrayRef or CFMutableArrayRef. Most CFArrayRefs are __NSArray* these days, even when created via CF, so this will generally only be one with a custom allocator or custom callbacks.
Dictionaries
__NSDictionary0 - a singleton empty immutable NSDictionary. Makes @{} and [NSDictionary dictionary] very efficient.
__NSSingleEntryDictionaryI - an immutable NSDictionary that stores one key-object pair. Avoids having to do any hashing. Useful for things like APIs that take options as a dictionary argument.
__NSDictionaryI - an immutable NSDictionary backed by an inline linear-probed hash table.
__NSFrozenDictionaryM - an immutable NSDictionary sharing its storage with an __NSDictionaryM that it was -copy'd from (usual CoW behavior)
__NSDictionaryM - a mutable NSDictionary backed by an out of line linear-probed hash table.
NSKeyValueChangeDictionary - a specialized dictionary for efficiently representing the 'change' argument to KVO
NSSimpleAttributeDictionary, NSAttributeDictionary - specialized dictionaries for storing attributed string attributes, which have a range as well as a key
NSOwnedDictionaryProxy - implementation detail of NSProgress
NSFileAttributes - implementation detail of NSFileManager
NSRTFD - implementation detail of RTF file support
NSLanguageContext - honestly no idea
_NSNestedDictionary - implementation detail of NSPredicate
__NSCFDictionary - a CFDictionaryRef or CFMutableDictionaryRef. Currently these are generated by CF even for default callbacks, unlike arrays.
NSSharedKeyDictionary - a dictionary that uses a perfect hash table to reduce memory costs and improve speed, for a predefined set of keys
Data
NSConcreteData - immutable NSData that stores its contents out of line and supports arbitrary deallocators
NSConcreteMutableData - NSMutableData that stores its contents out of line and supports malloc or vm_allocate
NSSubrangeData - proxy for another NSData that accesses only a subset of the original data's contents
_NSZeroData - singleton immutable NSData, makes [NSData data] efficient
_NSInlineData - immutable NSData that stores its contents inline
_NSClrData - immutable NSData that clears its contents with memset_s() before deallocating
_NSDispatchData - bridged dispatch_data_t, stores a tree of discontiguous contents
NSPurgeableData - NSMutableData that can allow its memory to be reclaimed by the system if needed when not in use
NSDOStreamData - implementation detail of NSPortCoder
__NSCFData - CFDataRef or CFMutableDataRef
@jaredjones

This comment has been minimized.

Copy link

commented Oct 7, 2017

AMAZING! Why is this not in the documentation for each Foundation class respectively?

@Jean-Daniel

This comment has been minimized.

Copy link

commented Oct 7, 2017

Because it make absolutely no sense to document implementation details. Especially that kind of details that change in every system release.

@samsonjs

This comment has been minimized.

Copy link

commented Oct 8, 2017

Why do some have underscores and others not? And different numbers of underscores at that. Mysterious.

@L05t

This comment has been minimized.

Copy link

commented Apr 3, 2018

__NSFrozenArrayM - an immutable NSArray sharing its storage with an NSMutableArray that it was -copy'd from (will do a real copy if the original array is mutated)
it`s usefully!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.