在 iPhone 应用程序中存储测验问题
我对 iPhone 开发非常陌生,所以如果这是一个太基本的问题,请原谅我。我正在开发一个测验应用程序,我需要从服务器获取测验问题,然后显示它们。我已经完成了检索部分,但我不知道可以在哪里保存它们,因为测验的设计是有 20 个问题,我必须在每个屏幕上显示 4 个问题,保存用户答案并在最后一个屏幕上计算评分并将其显示给用户。我只有四天的 iPhone 开发经验,所以任何形式的帮助将不胜感激。
i am very very new to iphone development so forgive me if its too basic a question. I am working on a quiz app and i need to get the quiz questions from a server and then show them. I have done the retrieving part but i dont know where i can save them because the design of the quiz is such that there are 20 questions and i have to show 4 on each screen, save the user answers and on the last screen, calculate the score and show it to the user. I have just a four day experience of iphone development, so any kind of help will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是将数据写入文件系统上的普通旧文件中。如果您将测验数据保留为 NSArray 或其他内容,则可以很简单:
这会将数组序列化为适合存储在文件中的格式,然后将其保存到文件中。
要读回它,您只需
获取合适的文件:
The easiest approach is just to write your data to a plain old file on the file system. If you keep the quiz data as an
NSArray
or something, it can be as easy as:This serializes your array into a format suitable for storing on file and then, well, saves it to the file.
To read it back, you just
To get a suitable file: