开发者

Need advice about how to cache text data on iPhone

Could you give me some开发者_如何学Go algorithm or example?


NSUserDefaults will nicely hold onto snippets of data.

Example:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    [window addSubview:tabBarController.view];
    if ([[NSUserDefaults standardUserDefaults] integerForKey:kTabIndexKey])
        tabBarController.selectedIndex = [[NSUserDefaults standardUserDefaults] integerForKey:kTabIndexKey];
}

- (void)applicationWillTerminate:(UIApplication *)application {
    [[NSUserDefaults standardUserDefaults] setInteger:tabBarController.selectedIndex forKey:kTabIndexKey];
}

Persists and loads an integer (your method would be "setString" and "stringForKey", check the docs.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜