Objective-C : Member variable is losing reference between method calls.
- by Winston
Hello,
I've been having with an objective-c class which appears to be losing its pointer reference between methods of the same class.
In the MyTableViewController.h file, I declare:
@interface SettingsTableViewController : UITableViewController <UITextFieldDelegate>{
OCRAppDelegate *delegate;
}
MyTableViewController.m file
- (id) init {
self = [ super initWithStyle: UITableViewStyleGrouped ];
delegate = [(OCRAppDelegate *)[[UIApplication sharedApplication] delegate] retain];
}
The problem is when the "MyTableViewController" view appears again and a different method is executed within that same class, the delegate pointer (which was assigned during the init method) is no longer there. I tried to retain, but to no avail.
Would anyone know why this is, it seems like perhaps it is a fundamental Objective-C issue which I am missing.
Appreciate your help.
Thanks,
Winston