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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:13:31+00:00 2026-06-10T02:13:31+00:00

For reference, I’m trying to learn Objective-C through the Stanford iTunes-U course. I wanted

  • 0

For reference, I’m trying to learn Objective-C through the Stanford iTunes-U course. I wanted to update one property from the setter of another (they are inherently connected. Also, is that bad style?). The property I am trying to update is a UILabel, but it doesn’t work like I thought.
This code is in one of my view controllers:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    [segue.destinationViewController setProgram:self.brain.program];
}

Naturally, this code calls the setter for the Program property of the incoming viewController. Here’s that setter code:

-(void)setProgram:(id)program {
    _program = program;
    self.title = [CalculatorBrain descriptionOfProgram:program];
    [self.graphview setNeedsDisplay];
    self.testLabel.text = @"Trying to update your text!";
}

and the header file:

#import <UIKit/UIKit.h>

@interface GraphViewController : UIViewController
@property (nonatomic, strong) id program;

@property (weak, nonatomic) IBOutlet UILabel *testLabel;

@end

Now, when this code is run, as the segue happens, the new view DOES have its title changed (the self.title line works). However, the UILabel DOES NOT get updated. Furthermore, if I call the setter again say in viewDidLoad, it does change the UILabel. Is this because of self being updated? What’s going on here?

  • 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-10T02:13:33+00:00Added an answer on June 10, 2026 at 2:13 am

    In one of the lectures, the professor explains that outlets aren’t set yet in prepareForSegue. This means testLabel is nil, and you’re sending a message to nil (which is allowed and doesn’t crash your app). To solve your problem, set the textLabel’s text in viewDidLoad or viewWillAppear.

    I believe this is “fixed” in iOS 6, but it won’t be backwards compatible, so if you want to support iOS 5 still, you’ll have to use viewDidLoad or viewWillAppear to update outlets (which I think is better to do anyway).

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

Sidebar

Related Questions

In reference to this bug from Sonar: http://jira.codehaus.org/browse/SONAR-1865 and this one (which cross references
With reference to the question regarding replicating values from one textbox to another Replicating
For reference, please visit this page here . When trying to get a view
With reference to Parse JSON in C# I am trying to parse the following
C++ reference types as instance variables are forbidden in Objective-C++. How can I work
The reference says this: You should call this function from the main thread of
To reference services exposed by one plugin into another Eclipse Plugin I have two
Reference I am trying to add code (a subroutine call) to a procedure within
reference from: Merging Variable PHP I have problem with $_POST getting blank null after
MSDN reference: [1] http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx#Y1178 From the link it says that the first argument will

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.