How to find out which control is being edited

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

  1. art0071 macrumors newbie

    May 20, 2009
    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 ( == "txt1") ...

  2. PhoneyDeveloper macrumors 68040


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

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

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

    May 20, 2009

Share This Page