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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:07:20+00:00 2026-05-13T20:07:20+00:00

I am trying to release the label text each time the person click on

  • 0

I am trying to release the label text each time the person click on a book title from the table view, it should change the detailViewController label (titleLabel) however it keeps showing the same book title.

Wondering If i have done something wrong – well I know I have but wondering how I fix it…

//
//  BookDetailViewController.m

#import "BookDetailViewController.h"
#import "Book.h"

@implementation BookDetailViewController

@synthesize aBook, titleLabel;

// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
    [super viewDidLoad];
    [self bookDes];
    self.title = @"Book Detail";
}

-(void)bookDes {
    [self.titleLabel setText:nil];

    [self.titleLabel setText:aBook.title];
}

- (void)dealloc {
    [aBook release];
    [titleLabel release];
    [super dealloc];
}
@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-05-13T20:07:20+00:00Added an answer on May 13, 2026 at 8:07 pm

    You are calling [self bookDes] from viewDidLoad… This method is called after a view controller has loaded its associated views into memory. How are you creating the BookDetailViewController? If you only create it once and then reuse the controller each time a user presses a book title, the viewDidLoad method will also only be called once.

    If you already have the book title in your parent controller, why don’t you just set the property from there when you push the child onto the navigation controller?

    bookDetailsController.titleLabel.text = selectedBook.title;
    

    EDIT FROM COMMENT:

    Yes, the BookDetailsViewController is created once, then saved… so the viewDidLoad is only called once.

    One thing you could try is setting the label in the parent’s didSelectRowAtIndexPath method:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        // Navigation logic -- create and push a new view controller
    
        if(bdvController == nil)
            bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];
    
        Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
    
        bdvController.aBook = aBook;
        bdvController.titleLabel.text = aBook.title;
    
    
        [self.navigationController pushViewController:bdvController animated:YES];
    }
    

    there are better ways to do this like overriding the setter on the details controller and setting the label… but you should keep it simple and get it working first.

    Hope this helps

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

Sidebar

Related Questions

I am trying to move a JComponent say a label over a table.I am
As the title says, I'm trying to get an automated release job working on
I am trying to create a table view header with rounded corners but a
I'm trying to get a value from a NSTextField (Label) and convert it to
I am trying to release a custom view that utilizes WEPopoverController as well as
When I am trying to release the object of UIPopoverController ,app gets crashed with
I'm trying to get maven's release plugin working with Perforce. When I run: mvn
I am trying to use MSBuild release mode, but it always defaults to debug.
I'm trying to write a macro that toggles between release/debug solution configurations in Visual
I'm trying to utilize the parameter feature introduced in the v4 release, but I'm

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.