<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-c.protocol/retain",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(pl)NSObject(im)retain"
  },
  "title" : "retain"
}
-->

# retain

Increments the receiver’s reference count.

```
- (instancetype) retain;
```

## Return Value

`self`.

## Discussion

You send an object a [`retain`](/documentation/ObjectiveC/NSObject-c.protocol/retain) message when you want to prevent it from being deallocated until you have finished using it.

An object is deallocated automatically when its reference count reaches `0`. [`retain`](/documentation/ObjectiveC/NSObject-c.protocol/retain) messages increment the reference count, and [`release`](/documentation/ObjectiveC/NSObject-c.protocol/release) messages decrement it. For more information on this mechanism, see [Advanced Memory Management Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html#//apple_ref/doc/uid/10000011i).

As a convenience, [`retain`](/documentation/ObjectiveC/NSObject-c.protocol/retain) returns `self` because it may be used in nested expressions.

You would implement this method only if you were defining your own reference-counting scheme. Such implementations must return `self` and should not invoke the inherited method by sending a [`retain`](/documentation/ObjectiveC/NSObject-c.protocol/retain) message to `super`.

### Special Considerations

Instead of using manual reference counting, you should adopt ARC—see [Transitioning to ARC Release Notes](https://developer.apple.com/library/archive/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011226).

---

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)