I have two classes:
- RootViewController.h
- RootViewController.m
In my RootViewController.h
// in .h file
UITextField* myTextField_;
@property (nonatomic, retain) UITextField* myTextField.
In my RootViewController.m
// in .m file
@synthesize myTextField = myTextField_
// in dealloc
[myTextField_ release]
// in viewDidLoad
UITextField* tf = [[UITextField alloc] init] initWithFrame:CGRectMake(200,6,100,30)];
[nameTextField_ = tf];
[tf release]
My question is,
Does that create any memory leaks? Or will that crash? Are there better ways to create an instance of UITextField so I keep a reference to it? Perhaps
myTextField_ = [[UITextField alloc] init] initWithFrame:CGRectMake(200,6,100,30)];
would that be sufficient?
The simpliest way is to do this like this:
.h:
.m
You will have one instance which is allocated and released in most clean way and you will have reference to this textfield all the time.