当我在iOS4.2上运行以下代码时,会保存默认值。 但是当我在5.0中运行时,他们会在用户关闭时丢失(完全关闭应用程序)。
我错过了什么? THX
- (void) setupSave:(UIButton*)btn
{
//save IP and Port
strTcpIpAddress = [tvTcpIpAddress text];
strTcpPort = [tvTcpPort text];
[[NSUserDefaults standardUserDefaults] setObject:strTcpIpAddress forKey:@"tcpIpAddress"];
[[NSUserDefaults standardUserDefaults] setObject:strTcpPort forKey:@"tcpPort"];
[tvTcpIpAddress resignFirstResponder];
[tvTcpPort resignFirstResponder];
}
OnStartUp:
//NSUserDefaults
strTcpIpAddress = [[NSUserDefaults standardUserDefaults] stringForKey:@"tcpIpAdress"];
strTcpPort = [[NSUserDefaults standardUserDefaults] stringForKey:@"tcpPort"];
//userName = NULL;
if(strTcpIpAddress == NULL) strTcpIpAddress = @"10.0.0.7";
if(strTcpPort == NULL) strTcpPort = @"4000";
plist中: