---
title: "Is condition is necessary before releasing instance"  
description: "Is condition is necessary before releasing instance"  
author: "Anonymous User"  
published: 2015-11-03  
updated: 2015-11-04  
canonical: https://www.mindstick.com/forum/33567/is-condition-is-necessary-before-releasing-instance  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Is condition is necessary before releasing instance

Whenever I [release](https://www.mindstick.com/news/2247/apple-plans-to-release-new-macs-in-early-2023) any [instance](https://www.mindstick.com/forum/155658/testing-connection-to-cloud-sql-instance-with-a-mysql-client-from-vm-instance) that could [exists](https://www.mindstick.com/forum/158947/how-do-you-use-the-exists-operator-to-check-for-the-existence-of-records-in-a-subquery) or not, I am using this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
if(myObject!=nil){   [myObject release];}
```

but I have a confusion, sending a [message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net) to nil is not a [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic);\
I want to know, is that [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition) necessary?\

## Replies

### Reply by Tarun Kumar

There is no need to check nil, because by default Objective C checks for nil,\
So there is no need to check it twice.

```
[myObject release]; myObject = nil;
```

but, you can do some extra code with that object here, before releasing the object.


---

Original Source: https://www.mindstick.com/forum/33567/is-condition-is-necessary-before-releasing-instance

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
