保存用户名和高分的最佳方法是什么
在我的应用程序中,我需要保存一个双值(高分)和字符串(玩家名称),我应该使用什么来获得这个。
任何想法都会很棒。
谢谢
In my app I need to save a double value (high score) and String (player name) what should i use to get this.
any idea will be great.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这就是您要保存的全部内容,则 NSUserDefaults 应该没问题
If this is all you're saving then NSUserDefaults should be fine
正如 deanWombourne 所说,您可以使用 NSUserDefaults 来存储这些数据,但它不是很安全。如果您不想“空中”存储这些数据,您可以查看 SFHFKeychainUtils by Buzz Andersen 将它们存储在 iPhone 钥匙串中。
首先,将 SFHFKeychainUtils 文件复制到您的项目中。单击 SFHFKeychainUtils.m,然后单击“获取信息”。转到目标选项卡并检查目标附近的框是否已选中。如果没有,请检查一下。按住 Control 键单击您的 Framework 文件夹,然后选择“添加现有框架”。找到 Security.framework 并将其添加到您的项目中。还可以通过执行与 SFHFKeychainUtils.m 相同的过程来检查该框架是否已添加到您的目标中。现在,在要使用此代码的位置打开您的实现文件,并在顶部添加
#import "SFHFKeychainUtils.h"
。这是一个有关如何使用此代码的小示例:
As deanWombourne said, you can use NSUserDefaults to store these data but it isn't very secure. If you don't want to store this data "in the air", you can take a look to SFHFKeychainUtils by Buzz Andersen to store them in the iPhone Keychain.
First of all, copy SFHFKeychainUtils files to your project. Click on the SFHFKeychainUtils.m and click on Get Info. Go to Target tab and check if the box near your target is checked. If not, check it. Control-click on your Framework folder and select Add Existing Framework. Find Security.framework and add it to your project. Check also that this framework is added to your target by doing the same procedure done for SFHFKeychainUtils.m. Now open you implementation file on where you want to use this code and add on the top
#import "SFHFKeychainUtils.h"
.This is a little example on how to use this code: