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

The Archive Base Latest Questions

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

pass data from FirstViewController to DetailViewController. i can not set the text of label

  • 0

pass data from FirstViewController to DetailViewController. i can not set the text of label in DetailViewController; FirstViewController is a tableview and it is good.

i use method updateRowNumber to set the rowNumber . and in DetailViewController, i can use debugger to see the rowNumber is correct. but the label’s text is not showed on the view.

anyone can help me out?

in my FirstViewController

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

if (dvController == nil)
{
    DetailViewController *aController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];

    self.dvController = aController;

    [aController release];
}   

[[self navigationController] pushViewController:dvController animated:YES];
[dvController updateRowNumber:indexPath.row];


}

in my DetailViewController.h

#import <UIKit/UIKit.h>

@interface DetailViewController : UIViewController
{
    int rowNumber;
    IBOutlet UILabel *message;
}

@property(readwrite) int rowNumber;
@property(nonatomic, retain) IBOutlet UILabel *message;
- (void) updateRowNumber:(int) theindex;


@end

in my DetailViewController.m

#import "DetailViewController.h"


@interface DetailViewController ()

@end

@implementation DetailViewController

@synthesize message, rowNumber;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void) updateRowNumber: (int) theindex
{
    rowNumber = theindex + 1;
    message.text = [NSString stringWithFormat:@"row %i was clicked", rowNumber];
}

- (void)dealloc
{
    [message release];
    [super dealloc];
}

- (void)viewDidLoad
{
    message.text = [NSString stringWithFormat:@"row %i was clicked ", rowNumber];
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewWillAppear:(BOOL)animated
{
    //message.text = [NSString stringWithFormat:@"row %i was clicked ", rowNumber];

    [super viewWillAppear: animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear: animated];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
  • 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-14T02:27:12+00:00Added an answer on June 14, 2026 at 2:27 am

    You’ll need to learn how the view is loaded, the process is well described in the documentation

    What happens is that the view and all the outlets are nil until the view is loaded, you can make sure it is loaded by calling self.view; before configuring the outlet at updateRowNumber:


    Please also note, you are better to call [super viewDidLoad] in the beginning of the overridden viewDidLoad, it makes sense as you need to let UIViewContorller to do it’s staff before you do some customized logic, the dealloc is different as you need to do your logic before the standard NSObject -dealloc fires. Hope it’s understandable.

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

Sidebar

Related Questions

My app in ASP.NET C#, i use linq to sql to pass data from
I'm trying to use __doPostBack to pass some data from client to server side.
How can I pass data from one form to another in Qt? I have
How can I pass data from client to server? I have a very simple
Can some one tell me how to pass data from controller to a data
Have one Doubt In MVC Architecture we can able to pass data from Controller
I understand that there's a set of methods used to pass data from one
How can I pass data from a threaded service to the activity that created
Does anyone know if I can pass data from flash (action script) to java
Anyone can detail the pros and cons to pass data from one class to

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.