UITextField and knowing which one was first responder

I have a app with several UITextFields and I want to know which textfield was the first responder within the function.
ie I have a text field created in interface builder and its outlet is assigned to nameField.
So how can I know when nameField was the one that received the input from the keyboard of DONE ??
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    return YES;
I've tried
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    [theTextField resignFirstResponder];
    if(theTextField == nameField)
        NSLog(@"I got here");
    return YES;
But my NSLog output is not sent, so I don't know why theTextField is evaluating to false.
Thanks

Take a view based application and name it as textField.
Make Sure that in interface builder set each textField delegate to File's Owner. Otherwise it won't work.
Here is the code:
textFieldViewController.h
#import <UIKit/UIKit.h>
@interface textFieldViewController : UIViewController <UITextFieldDelegate> {
          UITextField *textField1;
          UITextField *textField2;
          UITextField *textField3;
          UITextField *textField4;
          UITextField *textField5;
@property (nonatomic, retain) IBOutlet UITextField *textField1;
@property (nonatomic, retain) IBOutlet UITextField *textField2;
@property (nonatomic, retain) IBOutlet UITextField *textField3;
@property (nonatomic, retain) IBOutlet UITextField *textField4;
@property (nonatomic, retain) IBOutlet UITextField *textField5;
@end
textFieldViewController.m
#import "textFieldViewController.h"
@implementation textFieldViewController
@synthesize textField1;
@synthesize textField2;
@synthesize textField3;
@synthesize textField4;
@synthesize textField5;
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
          [theTextField resignFirstResponder];
          if (theTextField == textField1)
                    NSLog(@"I Got here");
          return YES;
- (void)dealloc {
          [textField1 release];
          [textField2 release];
          [textField3 release];
          [textField4 release];
          [textField5 release];
    [super dealloc];
@end

Similar Messages

  • How Do I Know Which commandButton was Clicked in the Validation Phase?

    I have three <h:commandButton ... /> components in a single form. In order to implement some validation rules, I need to know which one was clicked. I cannot rely on the configured actionListener methods because they have not yet been invoked in the JSF life-cycle.
    It seems that the components representing each of these buttons get created and their values are all set to null. So that doesn't help.
    I could set a hidden field using a JavaScript onclick event handler, but that seems to be a hack for something that any decent web application framework should be able to handle elegantly.
    Thanks in advance for any help.
    Atif Faridi

    Thanks for the quick reply.
    I considered that, but ruled it out as an option because I was convinced that JSF would offer something better.

  • Recover Accidentally Deleted Icon (and I don't know which one it was)

    I accidentally dragged an icon off of the dock and didn't see which one it was. It doesn't show up in my trash barrel. Anyway to recover or find out which icon it was?
    Thanks!

    Unless you have a backup of your drive to which you can boot and see which one is missing I doubt there is any way. It probably doesn't make any difference anyway. If you find you need something on the dock you can drag it there. Maybe eventually you'll notice which one it was that way.

  • I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?

    I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?

    Thanks, this is not an ideal answer but probably the most sensible one in my case.
    I will try it unless someone has a better suggestion, but I'll wait a bit as it will take me a few days anyway (I had actually tried to create a new smaller playlist or download by album, but at this stage the music app is not letting me queue a list of songs for download - I think I will have to disable and re-enable iTunes match which will probably delete all the songs).
    I have to say I am not very impressed with Apple here - having an online backup of all your data and beeing able to restore it to a new device easily was a strong selling point of iCloud. For music, they are Definitly not delivering at the stage.

  • I am about to buy my first ipad but dont know which one to buy.  I will use it for email, browsing, watching films etc -Please help me!

    I am about to buy my first ipad but don't know which one to choose and all the information baffles me!!  I will use it for email, browsing, watching films, general things like that.  Please help?

    I'm sure others will disagree, but I'm all about saving $.  I would start by looking online at the Apple store for refurbished devices.  I would also get MORE memory than yout think you will ever need.  The    stuff we have seems always to expand to fill the space available.  I wouldn't get one with cellular capability unless you really, really need it...
    http://store.apple.com/us/browse/home/specialdeals/ipad

  • No sound today. Maybe because I turned the sound off on a free game app but now don't know which one and probably deleted the app.

    No sound today. Maybe because I turned the sound off on a free game app yesterday but now don't know which one and probably deleted the app.

    It's pamonvashon again (the person who posted the question).  I fixed it so I'll tell you how in case it happens to you.  I was correct.  I went back and re downloaded the game,  "Virble".  At the beginning of the game o I used the buttons on the side of the phone to turn the sound off and on and the sound came on!  A miracle!  So beware of VIRBLE!!!

  • I send an email to several people and I get an undeliverable message, how do I know which one is undeliverable

    I send out a news letter for the Lions Club and involves 30 different people. Sometimes I get an undeliverable message and I don't know which address did not get delivered. How can I find out which one was not delivered so I can make sure I have all the correct data.

    Don't you get a full report? the message text look like this from my isp.
    The following message to <[email protected]> was undeliverable.
    The reason for the problem:
    5.1.0 - Unknown address error 550-'5.1.2 <[email protected]>: Recipient address rejected: Domain not found'
    Reporting-MTA: dns; ipb1.telenor.se
    Final-Recipient: rfc822;[email protected]
    Action: failed
    Status: 5.0.0 (permanent failure)
    Remote-MTA: dns; [213.150.xxx.xx]
    Diagnostic-Code: smtp; 5.1.0 - Unknown address error 550-'5.1.2 <[email protected]>: Recipient address rejected: Domain not found' (delivery attempts: 0)

  • Can you have multiple Apple TV's in the same house and network? If so how do you know which one to pick from your Idevice?

    can you have multiple Apple TV's in the same house and network? If so how do you know which one to pick from your Idevice?

    Yes, there are even defaults for naming them, such as LivingRoom, Bedroom, etc, or you can even enter your own name with the remote for each AppleTV.

  • Hi I wonder if I live in Bangkok and like to have my own website who should I use for hosting so many of them and how do I know which one is a good one thank you

    Hi I wonder if I live in Bangkok and like to have my own website whshah old I use as hosting website? so many of them and how do I know which one is a good one thank you

    It doesn't really matter which country your hosting service is located in so long as they offer 24/7 tech support in your chosen language. Telephone support is usually free of charge to you.
    Some info about the essential features to look for...
    http://www.iwebformusicians.com/iWeb/Website-Hosting.html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • How do i get a password?  I changed my password last night and it doesn't work.  Or, it is asking for a password for something else and I do not know which one!

    how do i get a password?  I changed my password last night and it doesn't work.  Or, it is asking for a password for something else and I do not know which one!

    Usually when someone mentions "passowrd" in a posting it will not be related to an Adobe product but to the machine that you are trying to implement some installation or update for.  If you explain more about what you are trying to do and describe what you encounter it might be easier to determine what you are dealing with... include a screenshot to help explain as well if you can.

  • Difference between photoshop cc and photoshop cc 2014   how do i know which one I am using?

    difference between photoshop cc and photoshop cc 2014   how do i know which one I am using?

    Hi Petereas,
    Both are different version of Photoshop application.
    In Photoshop CC 2014 there are several new feature introduced than CC.
    Please refer the following page on whats new in Photoshop 2014.
    Photoshop Help | New features summary
    When you go to Help>About Photoshop then Photoshop 2014 shows version 2014.0.0 Release.
    Hope this helps.
    Thanks and Regards,
    Sumit Singh

  • I have a budget of $2,200 and I don't know what to buy; The MacBook Pro 15 inch for $2,199 or the MacBook Pro w/ Retina Display for $2,199. I LOVE playing games but I don't know which one would play games faster.Take note that I wont upgrade anything.

    The MBP w/ Retina Display is 2.3GHz but the other without Retina Display is 2.6GHz. So I don't know which one would play games absolutely flawlessly. I wont have the screen resolution so high on the games though. So can someone reply and tell me which one I should get and why?

    Mac's are generally not 3D gaming computers and laptops especially are not because 3D games require a upgraded video card to take advantage of newer games and more feature rich updates.
    Only the Mac Pro can one change the video card, if one can find a upgrade for it.
    If you really love 3D gaming, a Windows 7 3D gaming tower is your machine.
    http://www.cbscores.com/index.php?sort=ogl&order=desc
    3D gaming on a Mac is sort of a second hobby, it's rather short lived as one can't replace the video card once a year, only with a new machine purchase.
    Most 3D games are for Windows anyway and Apple almost demands OS X be upgraded to newer verisons annually now, so that sort of throws a monkey wrench into a Mac gaming rig with software upgrades and all. On the other hand Windows 7 is supported for a decade.
    Mac's just don't work well with 3D gaming, perhaps a Win 7 tower and a iPad or something.

  • Lost my iphone dont know my IMEI number tried to get it from ituens about and clicking the Control key but there is one imei and i have 2 phones backed up on my ituens is there a way to know which one is the right one?

    Lost my iphone dont know my IMEI number tried to get it from itunesby clicking about and the Control key but there is one imei and i have 2 phones backed up on my itunes is there a way to know which one is the right one? and is there another way to find my phone and its offline so i cant use find my phone! Help

    Other ways? Check the box? Call your carrier?

  • Everytime i want to do the upgrade for firefox3.6 it asks what folder i wish to put it in and i don't know which one.

    Everytime i try to download firefox3.6 it says if i wish to run or save the file (I say run),then it says something about a temp. file and I say to run.Then it asks me what file i wish to use and I don't know which one.If i use Mozilla,then it kicks me out and it won't let me get the newer version.

    Have you tried using '''Help''' > '''Check for Updates''' while in an Admin account to allow Firefox to update itself?

  • I appear to have a duplicate library folder which is taking up a lot of space (one outside my user profile and one inside). How do I know which one to delete?

    I seem to have duplicated my 'Library' folder - one inside and one outside my USER folder. (additionally there is a Library folder in the systems folder - but that should be there!).  I do not know which one to delete (both 8-10 GB) Help!!

    There should be at least THREE Library folders:
    1- Inside your "home" folder, the one with your user name.
    2- At the "root" level of your boot volume.
    3- Inside the System folder at the "root" level of your boot volume.
    If it's one of those three, ignore them - especially if you don't know exactly what you're doing.
    If it's some other Library folder just floating around somewhere, you can safely delete it. Note that every user account will have its own Library folder inside its "home" folder, and these you should also leave alone.

Maybe you are looking for