What is the difference between release and nil

Posted by HML on Stack Overflow See other posts from Stack Overflow or by HML
Published on 2012-06-12T04:15:30Z Indexed on 2012/06/12 4:40 UTC
Read the original article Hit count: 105

Filed under:

I am new to iPhone SDK. I want to know that what is difference between release and nil. Yes, basic, I know. But my application crashing every time when I use release. If I use nil then its working fine. Here is code :

cellName=[cellArray objectAtIndex:5];
UITextField *txtFieldTown = (UITextField *)[cellName.contentView viewWithTag:2];
StrTown=txtFieldTown.text;
[txtFieldTown release];
txtFieldTown = nil; 

Here, if release line is removed, then its working fine. I know that I am not allocating txtFieldTown,so I should not worry but its retain count is 4. So I am trying to decrease that. Please help me.Thanking you...

© Stack Overflow or respective owner

Related posts about iphone