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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:32:32+00:00 2026-05-26T06:32:32+00:00

Im trying to get this to work, let me explain what im trying to

  • 0

Im trying to get this to work, let me explain what im trying to do and then i will show some code. Alright so i have a UITableView with a navigation controller, when you select a row, it loads a detail view.

I have made a string that will carry what row was selected, so i can know what to display on the view. The string wont pass between these two classes, and just comes up with null, even when i try to NSLog the string in another method within the same class it still comes up with null, the only place it will actually display whats inside it is in the method it was created.

Let me show you some code, i am trying to different ways to do it, and both come out with null
first class.h

@interface features : UITableViewController{

NSMutableArray *featuresTableViewSet;

NSString *selectedFeature;
}

@property (nonatomic, retain) NSMutableArray *featuresTableViewSet;
@property (nonatomic, retain) NSString *selectedFeature;

-(NSString *)get;
@end

first class.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath   *)indexPath
{
selectedFeature = [[NSString alloc]init];
selectedFeature = [featuresTableViewSet objectAtIndex:indexPath.row];


// Navigation logic may go here. Create and push another view controller.

 features_detail *detailViewController = [[features_detail alloc]     initWithNibName:@"features_detail" bundle:nil];
 // ...
 // Pass the selected object to the new view controller.
 [self.navigationController pushViewController:detailViewController animated:YES];



}

-(NSString *)get{
NSLog(@"%@", selectedFeature);
return selectedFeature;
}

Now here is the class im attempting to use the string in

i #import "features.h" the first class into the second one

here is the .m for the second class

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

features *selected = [[features alloc]init];

self.title = selected.selectedFeature;

NSLog(@"%@", [selected get]);

NSLog(@"%@", selected.selectedFeature);
}  

One of the two things im doing should work right?

Thanks 🙂

  • 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-26T06:32:33+00:00Added an answer on May 26, 2026 at 6:32 am

    Oh, no, this won’t work this way. You should create NSString property in the detail view class .h file:

    @interface features_detail : <bla-blaController> {
    
    NSString *selectedFeature;
    
    }
    
    @property (nonatomic, retain) NSString *selectedFeature;
    

    After you create detailViewController instance, you can initialize this property with they value you get from the table and then push the controller:

    features_detail *detailViewController = [[features_detail alloc]     initWithNibName:@"features_detail" bundle:nil];
     //pass it like this:
     detailViewController.selectedString = selectedFeature;
    
     [self.navigationController pushViewController:detailViewController animated:YES];
    
    // Now don't forget to release the controller you've pushed:
    [detailViewController release];
    
    //Oh, and you need to release the string as well:
    [selectedFeature release];
    

    This will help to avoid memory leakage because of the unreleased object.

    You don’t need the get method in here, by the way.

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

Sidebar

Related Questions

I have been trying to get this to work correctly and I think I
I've been trying to get this code to work for hours! All I need
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
I am trying to get this to work but can't see where I'm going
I've spent too much time trying to get this to work on IE 7.
I'm getting all in a twist trying to get this to work. New to
I've been trying to get this module to work and no matter what I've
I'm trying to get this expression to work, I'm pretty sure its not the
I am trying to get this script to work. it opens up a directry
I'm trying to get this thing to work in IE (any version - 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.