sharing text between views. -changing label text.

Discussion in 'iPhone/iPad Programming' started by natanavra, Jan 4, 2009.

  1. macrumors newbie

    Dec 26, 2008
    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.

Share This Page