开发者

iphone Development - data persistance UI

I have a UILabel that is modified while using my a开发者_StackOverflow中文版pp. I want the text of this UILabel to be saved even after I close the app.

What's the easiest way for doing this?


Save the content when the app is about to quit.

- (void)applicationWillTerminate:(UIApplication *)application
{
    [[NSUserDefaults standardUserDefaults] setObject:label.text forKey:@"label"];
}

And when you create the label, use the saved text.

label.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"label"];


NSUserDefaults will help you with this !

Watch this tutorial on how to use NSUserDefaults for storing/ saving data - Save Data In Your iPhone App Using NSUserDefaults Tutorial

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜