<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/class_createInstance(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:@F@class_createInstance"
  },
  "title" : "class_createInstance(_:_:)"
}
-->

# class_createInstance(_:_:)

Creates an instance of a class, allocating memory for the class in the default malloc memory zone.

```
func class_createInstance(_ cls: AnyClass?, _ extraBytes: Int) -> Any?
```

## Parameters

`cls`

The class that you want to allocate an instance of.

`extraBytes`

An integer indicating the number of extra bytes to allocate. The additional bytes can be used to store additional instance variables beyond those defined in the class definition.

## Return Value

An instance of the class `cls`.

## See Also

[`objc_constructInstance`](/documentation/ObjectiveC/objc_constructInstance)

Creates an instance of a class at the specified location.



---

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)