开发者

Best way to store a string in an iPhone app?

I've started a new iPhone app that needs to remember a single, 40-char string. That's it. I've hooked into Core Data, and am reading about it now, but it really s开发者_如何学Goeems like overkill. Is there an easier way to do something so simple?


NSUserDefaults would probably be the easiest way

// To Save
[[NSUserDefaults standardUserDefaults] setString:myString forKey:kMyStringKey];

//To Load
NSString * myString = [[NSUserDefaults standardUserDefaults] stringForKey:kMyStringKey];

This will persistence between sessions.

Edit: This is assuming of course that the string is not constant for everyone using the program. If it is you can just hard code it. This is for if every instance of the app needs a different string, but you want the string saved between runs of the app.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜