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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:49:02+00:00 2026-05-27T21:49:02+00:00

I am using a navigation based iPhone application, and I defined an IBOutlet propert

  • 0

I am using a navigation based iPhone application, and I defined an IBOutlet propert in the inner view and synthesized it,

The issue is when I want to set the IBOutlet value before pushing the new view controller, the value won’t be set. Here is a snippet from the code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    MealDetailViewController *mealViewController = [[MealDetailViewController alloc] initWithNibName:@"MealDetailViewController" bundle:nil];

    MealsModel *model = (MealsModel *)[_items objectAtIndex:indexPath.row];

    NSLog(model.Name);// here it writes the name right as a string

    //mealViewController.lblName.text=model.Name;

    [[mealViewController lblName]setText:model.Name];
    [[mealViewController txtDesc]setText:model.Description];

    [self.navigationController pushViewController:mealViewController animated:YES];

    [mealViewController release];
}

I didn’t face like these issues in the previous versions of Xcode.

  • 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-27T21:49:03+00:00Added an answer on May 27, 2026 at 9:49 pm

    It’s to do with when your view controller’s views are being created.

    When you do

    [[mealViewController lblName] setText:model.Name];
    

    you haven’t loaded it’s view yet so lblName will be nil.

    Try either

    (a) Explicitly asking for the view, triggering the subviews to be created :

    [mealViewcontroller view];
    [[mealViewController lblName]setText:model.Name];
    [[mealViewController txtDesc]setText:model.Description];
    

    or

    (b) Letting the navigation controller create the views for you

    [self.navigationController pushViewController:mealViewController animated:YES];
    
    [[mealViewController lblName]setText:model.Name];
    [[mealViewController txtDesc]setText:model.Description];
    

    or

    (c) Store the values in the mealViewController as properties

    MealViewController.h

    @property (nonatomic, copy) NSString *lblNameString;
    @property (nonatomic, copy) NSString *txtDescString;
    

    MealViewcontroller.m

    @synthesize txtDescString, lblNameString;
    

    and instead of setting the label directly, set the properties instead.

    [mealViewController setLblNameString:model.Name];
    [mealViewController setTxtDescString:model.Description];
    

    Then, in your newWillAppear, setting them

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        lblName.text = lblNameString;
        txtDesc.text = txtDescString;
    }
    

    (c) is the more correct way to do it – (a) and (b) both fail if your view controller’s view is unloaded by a low memory warning.

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

Sidebar

Related Questions

i am using navigation based application but i want to pop my view from
Situation: I am using the Navigation Based Application project template. And my root view
i'm making a navigation based application for iphone. one of my view controllers looks
I'm using a navigation based view controller on my iPhone app that uses an
I've created an application using the Navigation-based template in Xcode. I've also created a
Using the basic starting app from XCode for a navigation based application, I'm trying
I'm building a navigation controller based iPhone application and am curious how to go
I have a navigation based application using Core Data and several levels of drill-down
My app is a Navigation based application. The main menu contains the list view
I'm developing an iPhone application and I started out with the navigation based template.

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.