tags:

views:

50

answers:

2

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
A: 

sounds like your outlet might not be connected ?

Ican Zilb
It is connected, because I can see my buttons on it. and on clicking button I can change by label to some hard coded text.
Akki
Show me the code that you click on the button and set the label, please
vodkhang
lbl.text = @"Some Thing"; // hard coding is working.
Akki
lbl.text = name; //it is not working, name is my NSString which i am populating in my instance method.
Akki
A: 

You probably failed to connect your lbl Oulet in Interface Builder. Select your View Controller in interface builder, look at the connections section and connect lbl to the UILabel object in the View.

MarkPowell
When i use NSLog("Here %@",rest_name); in viewdidLaod I am getting warning "warning: passing argument 1 of 'NSLog' from incompatible pointer type"
Akki
The correct one for NSLog(@"Here %@",rest_name)
vodkhang
NSLog is showing the rest_name : null, I have updated the question to show what I am populating in rest_name in my class method
Akki
But the name and the rest_name is different, you are talking about 2 different problems. Show me the code you init the name
vodkhang
Please check updated question, thanks.
Akki