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

  • Home
  • SEARCH
  • 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 7713965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:00:17+00:00 2026-06-01T02:00:17+00:00

so I am having this issue that has been driving me crazy for hours,

  • 0

so I am having this issue that has been driving me crazy for hours, and I feels so stupid because it seems so simple. I’ve been searching the web and messing around with the code for the last 3 hours and I still can’t figure it out 🙁

Before I start, I am using Xcode 4.3.1 and testing on iOS 5.1 (both simulator and physical device).

So here is what I’ve done so far:

  • Use storyboards to connect all my views
  • One of my views is a UITableViewController, and it links to a UIViewController (using ‘push’, and it works correctly going back and forth between the 2 views)
  • The UITableViewController subclass is called ScheduleViewController
  • The UIViewController subclass is called EventViewController
  • I have already populated all of my sections and table cells with the appropriate content (I’m using textLabel and detailTextLabel (this is not an issue)
    -For UIViewController, I have only added a label and generated an IBOutlet for the label called: headerLabel

This is what I am trying to accomplish:

  • When the user clicks on a table cell in ScheduleViewController, go to EventViewController (up to this point it works!)
  • Based on the selected table cell, pass the textLabel.text, detailTextLabel.text, and Section Header text to EventViewController (kind of works, all values appear with NSLog, but that’s it???)
  • I figured it’s best to start small, so I am going to start by setting the headerLabel text (in EventViewController), to the Section Header Text (in ScheduleViewController) — Once again this seems to be working when I check the value with NSLog, but when I try to set the actual text of headerLabel, it just displays and empty string 🙁

Here is where I am stuck and what I have tried so far:

  • Well first of all I’ve already done something exactly the same (except it was with iOS 4 and I was not using storyboards), what I did was in the didSelectRowAtIndexPath: method in the UITableViewController, I just did something like (and worked fine 🙂 ):

    EventViewController *eventViewController = [[EventViewController alloc] initWithNibName:@”EventViewController” bundle:nil];
    eventViewController.headerLabel.text = stringToPass;

  • So of course, that was the first thing I tried, and of course it didn’t works because that’s just how programming is haha.

  • So next I created a custom init method in my EventViewController:

    • (id) initEventTime: (NSString *) eventTime andName: (NSString *) eventName andDate: (NSString *) eventDate;
  • First I tried calling it in the didSelectRowAtIndexPath: method in ScheduleViewController, and it kind of worked, here is the method in EventViewController:

    //Method to initialize event time, name, and date.
    
    • (id) initEventTime: (NSString *) eventTime andName: (NSString *) eventName andDate: (NSString *) eventDate
      {
      self = [super initWithNibName:@”EventViewController” bundle:nil];
      if (self)
      {
      NSLog(@”my custom”);
      // Custom initialization

      //NSLog(@”%@”,eventTime);
      //NSLog(@”%@”,eventName);
      //NSLog(@”%@”,eventDate);
      NSString *mystr = [NSString stringWithFormat:@”%@”,eventDate];
      NSLog(@”1: %@”,mystr);
      [self setTheEventDate:eventDate];
      NSString *mystr2 = [self getTheEventDate];
      NSLog(@”2: %@”,mystr2);
      headerLabel.text = [self getTheEventDate];
      NSLog(@”label: %@”, headerLabel.text);
      NSLog(@”3: %@”, eventDate);

      //self.headerLabel.text = [NSString stringWithFormat:@”%@”,eventDate];
      }
      return self;
      }

  • And here is how I called the method in the didSelectRowAtIndexPath: method (in ScheduleViewController):

    EventViewController *evc = [[EventViewController alloc] initEventTime:timeValue andName:eventValue andDate:dateValue];

  • So as you can see above I first checked if the values appeared in the output window using NSLog, and they all did!

  • But when I tried to set the headerLabel text is still returned an empty string
  • So then I tried creating a getter and setter (as you can see above) in EventViewController, called getTheEventDate and setTheEventDate.
  • In those methods I simply setTheEventDate using the eventDate argument, and then get the value; and once again it appeared in the output window, but an empty string of headerLabel
  • I also tried using NSLog to get the value of eventDate, an NSLog to get the text value of headerLabel, and another NSLog to make sure eventDate was not null.
  • Here is the output from the output window:

    2012-03-31 my custom
    2012-03-31 July 28
    2012-03-31 2: July 28
    2012-03-31 label: (null)
    2012-03-31 3: July 28

  • 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-01T02:00:18+00:00Added an answer on June 1, 2026 at 2:00 am

    If your view controllers are loaded from a storyboard, then anything concerning a nib is going to be a bad idea. 🙂

    The magic method for handling storyboard transitions is prepareForSeque:. Take a look at it; the segue has references to the controllers that are involved and the sender parameter links you to the control that initiated the action.

    Edit:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        EventViewController *next = (EventViewController *)[segue destinationViewController];
        next.headerLabel.text = @"Hello!";
    }
    

    In real code, you would need to use the sender to find out what actual information to pass by asking the table for the sender’s index path or something of that kind.

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

Sidebar

Related Questions

I have been having an issue with Visual Studio 2010 that is driving me
This is driving me crazy, and has been bugging me for weeks, I'm trying
I am having this issue. I have a script that checks if variable exists,
I am having some problems figuring out this issue. I have a server that
I have been having this issue in iterating through an array of keys and
UPDATE: Seems that railo doesn't have this issue at all. UPDATE: I'm voting to
This one has been driving me nuts for a few days now and I've
I have been wracking my brain on how to solve this issue for hours
I've been having this issue for a while now and was never really able
UPDATE: This issue has been fixed as of Xcode 4.6! This technique now works

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.