sharing text between views. -changing label text.

Discussion in 'iOS Programming' started by natanavra, Jan 4, 2009.

  1. macrumors newbie

    Joined:
    Dec 26, 2008
    #1
    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...
    Code:
    NSString *name = [[NSString alloc] initWithString:self.LoginViewController.Name.text];
    	[[NSUserDefaults standardUserDefaults] setObject:name forKey:@"pName"];
    	[[NSUserDefaults standardUserDefaults] synchronize];
    	[StatisticsViewController updatePlayerName:name];
    	[name release];
    

    Code:
    -(void)updatePlayerName: (NSString *)Name {
    	[playerName setText:Name];
    }
    
    ~Thanks in advance.
     

Share This Page