---
title: NSShouldRetainWithZone
framework: foundation
role: symbol
role_heading: Function
path: foundation/nsshouldretainwithzone
---

# NSShouldRetainWithZone

Indicates whether an object should be retained.

## Declaration

```occ
extern BOOL NSShouldRetainWithZone(id anObject, NSZone *requestedZone);
```

## Parameters

- `anObject`: An object.
- `requestedZone`: A memory zone.

## Return Value

Return Value Returns true if requestedZone is NULL, the default zone, or the zone in which anObject was allocated; otherwise false.

## Discussion

Discussion This function is typically called from inside an NSObject’s copyWithZone:, when deciding whether to retain anObject as opposed to making a copy of it. Special Considerations This function is deprecated and unavailable for use with ARC.

## See Also

### Object Allocation and Deallocation

- [NSAllocateObject](foundation/nsallocateobject.md)
- [NSCopyObject](foundation/nscopyobject.md)
- [NSDeallocateObject](foundation/nsdeallocateobject.md)
- [NSDecrementExtraRefCountWasZero](foundation/nsdecrementextrarefcountwaszero.md)
- [NSExtraRefCount](foundation/nsextrarefcount.md)
- [NSIncrementExtraRefCount](foundation/nsincrementextrarefcount.md)
