1
當我在iphone模擬器中輸入一個值並按下保存按鈕它只保留值,直到模擬器運行的值的問題。當我重新啓動模擬器並按下加載按鈕時,它會顯示me.i.e輸入的較早值,但它不能保留新值並只保留舊值。保存iphone
我正在使用以下循環來保存文件和加載文件。
-(IBAction) save{
NSUserDefaults *sinner=[NSUserDefaults standardUserDefaults];
[sinner setObject:serverIP.text forKey:@"load"];
NSUserDefaults *king=[NSUserDefaults standardUserDefaults];
[king setObject:noc.text forKey:@"save"];
}
-(IBAction) load {
NSUserDefaults *sinner=[NSUserDefaults standardUserDefaults];
NSString *tempstring =[sinner stringForKey:@"load"];
serverIP.text = [NSString stringWithFormat:tempstring];
NSUserDefaults *king=[NSUserDefaults standardUserDefaults];
NSString *tempstring1 =[king stringForKey:@"save"];
noc.text = [NSString stringWithFormat:tempstring1];
}
@thanks哥們它worked.canü提供socket編程索姆幫助。 – 2011-05-25 06:35:57
看到這個:[Socket programming](http://stackoverflow.com/questions/1083017/iphone-socket-program)。我對此沒有太多的想法:) – Nitish 2011-05-25 06:40:55
@ nitish感謝buddy – 2011-05-25 06:42:02