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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:24:24+00:00 2026-06-09T01:24:24+00:00

The code is from Stanford CS193p. I added a NSLog to check it out.

  • 0

The code is from Stanford CS193p. I added a NSLog to check it out. The label seems not being initialized. Any idea?

@interface AskerViewController() <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UILabel *questionLabel;
@property (weak, nonatomic) NSString *question;
@end


@implementation AskerViewController
@synthesize questionLabel = _questionLabel;
@synthesize question = _question;


 - (void)setQuestion:(NSString *)question
{
    _question = question;
    self.questionLabel.text = question;
    NSLog(@"label is %@", self.questionLabel);
}

@end

The NSLog result is:

2012-07-31 01:56:45.177 Kitchen Sink[23931:f803] label is (null)
  • 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-09T01:24:26+00:00Added an answer on June 9, 2026 at 1:24 am

    You are probably setting the question string property before you are displaying the view controller, presumably in prepareForSegue:? At this point, the view has not loaded and the label property will still be nil.

    You’re doing the right thing by having a separate string property, you’re just missing the step that you must also set the label’s text in viewDidLoad – at this point your label has been instantiated from the storyboard and is ready to use.

    If you’re setting properties before viewDidLoad is called, the label being nil is expected. And if you’re setting properties from prepareForSegue, the view won’t have been loaded yet. A view controller won’t load it’s view and subviews until it needs to display them on screen, and this doesn’t happen until the segue is being performed – and as you can guess, prepareForSegue is done before the segue is performed.

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

Sidebar

Related Questions

I have been studying the bonjour/NSStream sample code from lecture #17 of Stanford's CS193p
I recently started out with iOS programming (with the Stanford CS193P lectures from iTunes
Quoting the code for computing the integer absolute value (abs) without branching from http://graphics.stanford.edu/~seander/bithacks.html
I have the following C code to copy a linked list(taken from Stanford CS
I'm doing assignment 4 of cs193p from itunes u (fall 2011 Stanford iOS development
The code is from Stanford iOS developing course's Photomania app. Basically I want to
I am reading article from Stanford CS library http://cslibrary.stanford.edu/102/ Bad Pointer Example Code with
Retrieve code from json. C#code:- var collection = getsortcat.Select(x => new { idterm =
Porting code from 32bit to 64bit. Lots of places with int len = strlen(pstr);
Below is the code from internalRegister method of GCMRegistrar class static void internalRegister(Context context,

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.