views:

62

answers:

2
/*h file:*/

IBOutlet UITextField *Number;


/*m File:*/

[(Number) setText: [[NSUserDefaults standardUserDefaults]
stringForKey:@"SBFormattedPhoneNumber"]];

Any idea why this is not working ?

Thanks

+1  A: 

You probably have an empty or nil string as under that key.

Add this statement to check:

NSLog(@"%@", [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"]);
tadej5553
Not working at all :S and i know its not nil :/
Do you get the string you expected in the NSLog?
tadej5553
There is one more option that I see: you haven't connected the textfield in IB.
tadej5553
im sorry please explain
I'm not sure which one to explain, so I'll explain them both :D1. The output to the console.2. It means that you haven't dragged a line from that textfield to your object in interface builder (.xib file)
tadej5553
basically i can set text normally like: [(Number) setText:@"hi"]; but not with the number :S
Can you paste the console output of that NSLog?Might help a bit
tadej5553
i have read that they have disabled this :/ sorry for your time mate :)
They have disabled what?
tadej5553
A: 

Should read:

NSString * savedNumber = [[NSUserDefaults standardUserDefaults]
stringForKey:@"SBFormattedPhoneNumber"];
if (savedNumber)
{
     [Number setText:savedNumber];
}
Steve