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?



The class that you want to allocate an instance of.


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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software