<!--
{
  "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/NSObject-swift.class/init()",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)init"
  },
  "title" : "init()"
}
-->

# init()

Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.

```
init()
```

## Return Value

An initialized object, or `nil` if an object could not be created for some reason that would not result in an exception.

## Discussion

An [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()) message is coupled with an [`alloc`](/documentation/ObjectiveC/NSObject-swift.class/alloc) (or [`allocWithZone:`](/documentation/ObjectiveC/NSObject-swift.class/allocWithZone:)) message in the same line of code:

```objc
SomeClass *object = [[SomeClass alloc] init];
```

An object isn’t ready to be used until it has been initialized.

In a custom implementation of this method, you must invoke super’s [Initialization](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Initialization.html#//apple_ref/doc/uid/TP40008195-CH21) then initialize and return the new object. If the new object can’t be initialized, the method should return `nil`. For example, a hypothetical `BuiltInCamera` class might return `nil` from its `init` method if run on a device that has no camera.

```objc
- (instancetype)init {
    if (self = [super init]) {
        // Initialize self
    }
    return self;
}
```

In some cases, a custom implementation of the [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()) method might return a substitute object. You must therefore always use the object returned by [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()), and not the one returned by [`alloc`](/documentation/ObjectiveC/NSObject-swift.class/alloc) or [`allocWithZone:`](/documentation/ObjectiveC/NSObject-swift.class/allocWithZone:), in subsequent code.

The [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()) method defined in the `NSObject` class does no initialization; it simply returns `self`. In terms of nullability, callers can assume that the `NSObject` implementation of [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()) does not return `nil`.

---

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)