Why won't my textfield save to my singleton?

Go To StackoverFlow.com


I found, what I think to be, a decent example project on singleton classes here.

My question is:

What's up with

- (void)textFieldDidEndEditing:(UITextField *)textField

inside of the RootViewController.m and the SecondViewController.m (around lines 45-ish)? I understand how it works, but I don't see how it ever gets called or used.

2012-04-03 22:28
by user990769
Click on "here" - user990769 2012-04-03 22:36
Please put the code you are talking about into the body of your question - Josh Caswell 2012-04-03 23:10


They are triggered by delegation. If you check the nib (in IB), you will see that it has delegate the first responder or the class (RootViewController or SecondViewController).

So what it does is listen to the textfield for once the user presses the OK button to trigger the method above (which is defined to UITextFieldDelegate protocol).

2012-04-03 22:43
by Panagiotis
Yes, I did notice the delegation. But I found delegate references inside of File Owner, not inside of First Responder. Where exactly in First Responder would I find the delegate reference - user990769 2012-04-03 22:52
File Owner is ok (it happens there as well if you connect the text field delegate there). It means it's on the classes you mention above. I don't use IB often, so I define delegation differently - Panagiotis 2012-04-03 22:54
Baah. Yea. If I had been smart I wouldn't have used IB either...I just don't get it because I think I have all of that. The appropriate methods, the delegation connection from the text field to the file's owner, but when I try printing the string that gets saved on my project that function I have listed above never gets called - user990769 2012-04-03 23:01