<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/objective-c-runtime-utilities",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Objective-C Runtime Utilities"
}
-->

# Objective-C Runtime Utilities

Interact with the Objective-C runtime.

## Topics

### Type Lookup

[`func NSClassFromString(String) -> AnyClass?`](/documentation/Foundation/NSClassFromString(_:))

Obtains a class by name.

[`func NSStringFromClass(AnyClass) -> String`](/documentation/Foundation/NSStringFromClass(_:))

Returns the name of a class as a string.

[`func NSSelectorFromString(String) -> Selector`](/documentation/Foundation/NSSelectorFromString(_:))

Returns the selector with a given name.

[`func NSStringFromSelector(Selector) -> String`](/documentation/Foundation/NSStringFromSelector(_:))

Returns a string representation of a given selector.

[`func NSStringFromProtocol(Protocol) -> String`](/documentation/Foundation/NSStringFromProtocol(_:))

Returns the name of a protocol as a string.

[`func NSProtocolFromString(String) -> Protocol?`](/documentation/Foundation/NSProtocolFromString(_:))

Returns a the protocol with a given name.

### Serialization

[`func NSGetSizeAndAlignment(UnsafePointer<CChar>, UnsafeMutablePointer<Int>?, UnsafeMutablePointer<Int>?) -> UnsafePointer<CChar>`](/documentation/Foundation/NSGetSizeAndAlignment(_:_:_:))

Obtains the actual size and the aligned size of an encoded type.

### Object Allocation and Deallocation

[`extern idNSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);`](/documentation/Foundation/NSAllocateObject)

Creates and returns a new instance of a given class.

[`extern idNSCopyObject(id object, NSUInteger extraBytes, NSZone *zone);`](/documentation/Foundation/NSCopyObject)

Creates an exact copy of an object.

[`extern void NSDeallocateObject(id object);`](/documentation/Foundation/NSDeallocateObject)

Destroys an existing object.

[`extern BOOL NSDecrementExtraRefCountWasZero(id object);`](/documentation/Foundation/NSDecrementExtraRefCountWasZero)

Decrements the specified object’s reference count.

[`extern NSUInteger NSExtraRefCount(id object);`](/documentation/Foundation/NSExtraRefCount)

Returns the specified object’s reference count.

[`extern void NSIncrementExtraRefCount(id object);`](/documentation/Foundation/NSIncrementExtraRefCount)

Increments the specified object’s reference count.

[`extern BOOL NSShouldRetainWithZone(id anObject, NSZone *requestedZone);`](/documentation/Foundation/NSShouldRetainWithZone)

Indicates whether an object should be retained.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)