0

I am passing a string to another controller

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

CategoriesList *dvController = [[CategoriesList alloc] initWithNibName:@"CategoriesList" bundle:nil];

NSString *category=aBook.name;
dvController.category=category;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];

}

When I get value in dvController it does not show I am setting that to button title

 NSString *title=category;
 [titleButton setTitle:title forState:UIControlStateNormal];
4
  • Not parsing, it is called passing iVars values. Commented Aug 8, 2011 at 10:48
  • Check if you are passing any value? Then check if you have properly declared category (like property and synthesizing), then again use self.category, while using category in it's same class(where it is declared). if problem persist still, response. Commented Aug 8, 2011 at 10:50
  • Have you set property for category? Commented Aug 8, 2011 at 10:56
  • invalid CFString ref it shows when i debug Commented Aug 8, 2011 at 11:11

1 Answer 1

2

Easiest way is to create a custom init in CategoriesList:

CategoriesList.h

@interface DetailViewController : UIViewController
{
    NSString *category;
}

@property (nonatomic, retain) NSString *category;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil category:(NSString *)categoryName;

CategoriesList.m

@synthesize category;

...

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil category:(NSString *)categoryName;
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
    {
        self.category = categoryName;
    }
    return self;
}

...

- (void)dealloc
{
    [category release];
    [super dealloc];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.