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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:53:00+00:00 2026-06-02T07:53:00+00:00

I have the following code in my didSelectRowAtIndexPath delegate method: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

  • 0

I have the following code in my didSelectRowAtIndexPath delegate method:

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

    Exercise *exerciseView = [[Exercise alloc] initWithNibName:@"Exercise" bundle:nil]; //Makes new exercise object.

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *str = cell.textLabel.text; // Retrieves the string of the selected cell.

    exerciseView.exerciseName.text = str;

    NSLog(@"%@",exerciseView.exerciseName.text);

    [self presentModalViewController:exerciseView animated:YES];
}

In this, I try to take the text of the selected cell, and set the IBOutlet UILabel exerciseName to that string.

My method compiles, but when I run the NSLog, which prints the textvalue of the UILabel after setting it to str, it returns null. I feel like this is a pointer problem, but can’t seem to grasp it. Can anyone clarify things?

  • 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-02T07:53:02+00:00Added an answer on June 2, 2026 at 7:53 am

    The problem is the half-initialized view controller. Need to let it get built before you init the contents of a subview.

    Exercise.h

    @property(strong, nonatomic) NSString *theExerciseName;  // assuming ARC
    
    - (id)initWithExerciseName:(NSString *)theExerciseName;
    

    Exercise.m

    @synthesize theExerciseName=_theExerciseName;
    
    - (id)initWithExerciseName:(NSString *)theExerciseName {
    
        self = [self initWithNibName:@"Exercise" bundle:nil];
        if (self) {
            self.theExerciseName = theExerciseName;
        }
        return self;
    }
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        exerciseName.text = self.theExerciseName;
    }
    

    Call that new initializer from your didSelect method.

    Exercise *exerciseView = [[Exercise alloc] initWithExerciseName:str]; 
    

    But please get that str by using the logic within cellForRowAtIndexPath, not by calling it.

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

Sidebar

Related Questions

I have the following code : - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIWebView *aWebView;
Okay, so this is weird I have this code - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
I have this code in my table view controller (and delegate): - (void)tableView:(UITableView *)tableView
I've got the following code in one of my view controllers: - (void)tableView:(UITableView *)tableView
I have the following code: //in .h file: NSMutableDictionary* expandedSections; //in Init method: expandedSections
I have a strange problem with the following code: MembersDetailViewController *m = [[MembersDetailViewController alloc]
I have the following error. 'indexPath' undeclared (first use in this function) . Code
I was following the tutorial here . The code I have is: - (void)
I have the following code that gets called in didSelectRowAtIndexPath. The issue is, when
I have following code to play small audio files private void playVoice() { if

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.