Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I would like to be able to update myViewController's UILabel called score from myClass embedded in myViewController.

In myClass I created a pointer to myViewCOntroller called parent. I assigned the view pointer in the init of myClass using:

C#
MyAppDelegate * appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
self.parent = [appDelegate viewController];


I've forward declared the viewController in .h and imported to the the .m of myClass

When I get to the setLabel function in myClass, the parent pointer variable looks good, and so does the UILabel variable, and even the label's text but the label doesn't get updated after

CSS
NSString * text = [[NSString alloc] initWithFormat:@"Score, %d!", score];

parent.score.text = text;


Currently I'm creating the UILabel using the Interface Builder. I dragged from the control to the header file to create the variable and the preperty functions, and right-clicked on File's Owner to connect the control outlet to the variable.

I noticed that I can update the label form the viewController but not from myClass.

Any ideas of what I doing wrong?
Posted
Updated 12-Jun-12 19:16pm
v2

1 solution

Can you please put your code where you are setting label? Actually i need to see it in detail. Secondly are you calling this code from some secondary thread?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900