简体   繁体   English

Xcode中的NSUserDefault

[英]NSUserDefault in Xcode

I have a question on how can i use core date to update my formula. 我对如何使用核心日期更新我的公式有疑问。 I have tried using NSUserDefault but the formula is blank (its saves though). 我尝试使用NSUserDefault,但公式为空(尽管可以保存)。 So I have two textfields which needs to update my formula. 因此,我有两个文本字段需要更新我的公式。 And when the user quits the app the two textfield date needs to be saved. 并且当用户退出应用程序时,需要保存两个文本字段日期。 So how should I approach this way….. 所以我应该怎么做呢.....

Saving the content of a text field to the user defaults: 默认情况下,将文本字段的内容保存给用户:

[[NSUserDefaults standardUserDefaults] setObject:field1.text forKey:@"field1"];
[[NSUserDefaults standardUserDefaults] synchronize];

Loading the content of a text field from the user defaults: 默认情况下,从用户加载文本字段的内容:

[[NSUserDefaults standardUserDefaults] synchronize];
field1.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"field1"];

CoreDat a has little to do with saving simple things like that. CoreDat a与保存这样的简单事情几乎没有关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM