How to find out which control is being edited

Discussion in 'iOS Programming' started by art0071, Jun 4, 2009.

  1. art0071 macrumors newbie

    Joined:
    May 20, 2009
    #1
    Hello Guys,

    I am starting to plan now for the driven language
    and I object to a question that should be simple for you.

    Somebody could give me some advice on this:

    I have 2 UiTextField in the window, for each of them I created a
    "Outlet" and joined the names of txt1 and txt2.

    I created an IBAction and joined the event "did Begin Editing"
    for txt1 and txt2

    - (IBAction) trocarImagem (id): sender


    I would like to know how do I get the txt1 and test it
    by name.
    Something like this:? if (sender.name == "txt1") ...

    Thanks
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    The sender value is the object pointer of the control that sent the action. Something like this should work

    Code:
    if (sender == txt1)
    BTW, don't compare NSStrings with ==

    Code:
    if ([sender.name isEqualToString: @"txt1"])
    but textfields don't have names.
     
  3. art0071 thread starter macrumors newbie

    Joined:
    May 20, 2009

Share This Page