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 7415671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:20:49+00:00 2026-05-29T07:20:49+00:00

I have just started learning Objective-C / Cocoa Touch. I am working on an

  • 0

I have just started learning Objective-C / Cocoa Touch. I am working on an app that allows for creation of views on the fly (for the sake of this question lets just assume that clicking some button causes a button and label to be added to the current view)

So when a user clicks this ‘Create Button’ a new button and label is added to the current view. When a user clicks on the newly created button I want text in the newly created label to change to . Now I know that I can assign an IBAction to the button when I create it at runtime but I am not sure how to associate the new label with an Outlet.

Furthermore I want to do this with as little code as possible but I am not seeing how this is going to be possible. AFAIK the only way I can really identify the controls in the view is by their tag property which isn’t entirely helpful so I will have an event handler that ends up looking like this (pseudocode):

switch(tag)
{
   case 1:
   //label1.text = @"foo";
   break;

   case 2: 
   //label2.text = @"foo";
   break;
   //etc
}

In C# I could have done something like this (assuming e is of CommandEventArgs, all buttons are wired to this event, and CommandName contains the id of the label we want to update):

  Label lbl = (Label)panel1.FindControl(e.CommandName);
  lbl.Text = "foo";

So my questions are

  • Is it possible to assign/create Outlets at run time and associate them with a given label
  • Is there a better way of figuring out what label should be acted upon other than using a switch?

Thanks!

  • 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-05-29T07:20:50+00:00Added an answer on May 29, 2026 at 7:20 am

    The purpose of IBOutlets is generally to let you associate things created in Interface Builder with instance variables in your code. Since you are creating the views in code to begin with, it sounds like you should just be storing references to them in instance variables and not worrying about IBOutlets.

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

Sidebar

Related Questions

I have just started learning Objective-C, I am reading Programming in Objective-C 3rd Edition
I just started learning Objective-C and OOP ... so I have very stupid question
I have just started learning XNA. This is my first program that I am
I just started learning objective c. I have this little problems and questions, hope
Hi Just started learning c for uni (usually use objective c) and have run
Since I started learning Objective-C and Cocoa, I've been wondering why they have chosen
I have just started learning objective-C and the iphone sdk and I have a
I have just started learning Erlang and am trying out some Project Euler problems
I have just started learning Jquery and am new to writing javascript (I am
I have just started learning MVVM and having a dilemna. If I have a

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.