Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7950099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:09:53+00:00 2026-06-04T02:09:53+00:00

I have several textfields (and labels) in my XIB and at some point in

  • 0

I have several textfields (and labels) in my XIB and at some point in my application I build dynamicaly a string which contains a control name (i.e. one of the textfields).
How can I refer to the actual textfield using the string I created that holds the name of the textfield.

For example, I have txt1 , txt2, txt3, txt4 as UITextFields
and i have a string (str) that contains one of the fields above names (str =”txt3″)
then i want to change the content of the uitextfield txt3 since str have “txt3”
at this point.

How do I cast from the string to the actual control?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:09:55+00:00Added an answer on June 4, 2026 at 2:09 am

    If the UITextFields all have a backing property then you can use KVC to get a reference to the control and then you just use it as normal.

    NSString *str = @"txt1";
    UITextField *myTextField = [self valueForKey:str];
    myTextField.text = @"what ever you want to update to";
    

    Side note

    Although you have not mentioned the source of str @JefferyThomas raises a very valid point about not trusting use input that has not been validated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scroll view which contains several objects like text fields,labels,switch etc..Now as
I have several items textfields, labels, and images on a UIScrollView. Is there a
I have several textfields which will populate a text area. I managed to populate
I have several components on my UIView like textfields, labels, tables, buttons. I want
I have a UIVIew which is a subview and it contains several UITextFields. One
I have several TextField columns on my UserProfile object which contain JSON objects. I've
I have several Delphi programs that maintain connections to a database (some Oracle, some
we have several tens of macro enabled excel files, each of those contains few
I have a detail view with several textfields, next to one of them i
I have several text fields which compromise a registration form . When the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.