PDA

View Full Version : sharing text between views. -changing label text.




natanavra
Jan 4, 2009, 04:12 AM
Hi,
I'm building a simple game and I wish to implement a statistics view, with best player name and score, In one of the views the user is asked for his name and and from there I save it to the user Defaults.
Later on I wish to change the label text in the statistics view to the text which I saved earlier in the user defaults, every time I try to change the label's text it stays empty...
if it matter I implemented the whole interface through interface builder and linked it up (I use 'initWithNibName:').
every view has a view.m/h viewController.h/m and a nib...
here's my code...

NSString *name = [[NSString alloc] initWithString:self.LoginViewController.Name.text];
[[NSUserDefaults standardUserDefaults] setObject:name forKey:@"pName"];
[[NSUserDefaults standardUserDefaults] synchronize];
[StatisticsViewController updatePlayerName:name];
[name release];




-(void)updatePlayerName: (NSString *)Name {
[playerName setText:Name];
}


~Thanks in advance.