I want to set label on my new view (which I am loading on selection of table row) to variable NSString value, here is what I am doing
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int selected_row = [indexPath row];
SingleTon *index_instance = [SingleTon sharedInstanceIndex];
[index_instance setIndex:selected_row];
selected_row = [index_instance getIndex:selected_row];
NSLog(@"Selected row %d", selected_row);
[SelecetionViewController uploadthecontent:selected_row];
[self presentModalViewController:selection_controller animated:YES];
}
.h file contains
NSString *rest_name;
IBOutlet UILabel *lbl;
//Some class methods declared
.m file contains
- (void)viewDidLoad {
[super viewDidLoad];
lbl.text = rest_name;
}
//class method
+ (void)uploadthecontent:(int)data
{
SelecetionViewController *controller = [[SelecetionViewController alloc] init];
[controller labelset:data]; //calls labelset method which set rest_name to some value
[controller release];
}
-(void)labelset:(int)data{
[rest_name release];
SingleTon *indexinstance = [SingleTon sharedInstanceIndex];
SingleTon *rnameinstace = [SingleTon sharedInstance1];
//SingleTon *baddrinstance = [SingleTon sharedInstance2];
NSMutableArray *selected_rname;
//eNSMutableArray *selected_baddr;
int i = [indexinstance getIndex:data];
selected_rname = [rnameinstace getRName:selected_rname];
NSString * rname = [[NSArray arrayWithArray:selected_rname] objectAtIndex:i];
NSLog(@"Retaurant name : %@",rname);
//lbl.text = rest_name;
rest_name = [[NSString alloc] init];
rest_name = rname;
NSLog(@"I am here : %@",rest_name);
//[rest_name retain];
}
//rest_name is what I am trying to access and set as label