How can i keep track of 3 input strings from using 1 UITextField?
I am toggling between 3 different input types (departures, airlines, arrivals) using one UITextField for user input. I save each of the 3 in its own NSMutableString object like this(depending on what’s being entered or whatever):
depart = [input.text copy];
arrive = [input.text copy];
airline = [input.text copy];
i set the value of the UITextField(depending on what user is entering) using
input.text = [arrive copy];
input.text = [depart copy];
input.text = [airline copy];
i am successfully keeping track of each of the 3 inputs using input.text copy yet i am seeing memory leaking issues while running an Instruments test for leaks. i have a feeling it is a result of my improper cleanup of using copy. how can i retain each input string and not cause memory leaking issues?
Turn your strings into properties that are retained.
Set the value of the properties using self.
Without using self, you’re manually setting the value and bypassing the property, so the text is not retained.
Release the objects in your -(void)dealloc method
Then, when you’re editing specific information, you can use the properties to populate the textField
Does this make sense?