Tips and Tricks in iPhone Development
NO NEED TO RE-INVENT THE WHEEL

Assigning Variables

self.textField = [[UITextField alloc] int];

Do you think this is a good practice. It looks simple, but there is a hidden danger. After this step what is the retain counter for Text Field, that you have just created? Did you say it is one. No it is two already. Because it is retained by the setTextField property method and alloc method when it is created.

Correct it like this,

UITextField textField = [[UITextField alloc] int];
self.textField = textField;
[textField release];

Or assuming that you have textField_ variable as the name of the instance varibale,

textField_ = [[UITextField alloc] int];

No comments:

Post a Comment