Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pragyanshis

macrumors newbie
Original poster
Sep 27, 2011
2
0
I have defined a function in appdelegate like below.

Code:
- (void) ChangeLabelText:(NSString *)SenderP
{
TeenTaalViewControllerM = [[TeenTaalViewController alloc] initWithNibName:@"TeenTaalViewController" bundle:nil]; 
TeenTaalViewControllerM.view.hidden= NO;
[self.TeenTaalViewControllerM.lblLoopCountM setText:SenderP]; 
self.TeenTaalViewControllerM.lblLoopCountM.hidden = NO; 
}

and I am calling this function from a class like below

Code:
TeenTaalAppDelegate * TheAppDelegateL = [[UIApplication sharedApplication] delegate];
[TheAppDelegateL ChangeLabelText:@"Test"];



But the text of the UIlabel is not changing anyway !!!!please help !!!
 
You are creating a NEW instance of your TeenTaalViewControllerM class. This will result in the label on your view the first time, and the label you are trying to assign will have 2 different memory adresses. This will result, in you maybe setting the label, but the wrong one behind the scenes ;)
 
What happens when you log TeenTaalViewControllerM.view in that method? Then try to think about why you get this result.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.