建议在哪里存储iOS应用程序的数据 [英] Advise where to store data for iOS app

查看:104
本文介绍了建议在哪里存储iOS应用程序的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ionic和cordova创建了一个应用程序,现在我想在iOS上重新制作它。我是第一次使用iOS,我无法弄清楚如何存储数据。
例如:我有一个表单,用户必须输入一些数据,但输入不在一个视图中,必须有几个视图。我曾经创建空数组,只是一步一步地放置所有内容,但现在我不能在多个视图上使用相同的视图控制器。试图用核心数据来做,但核心数据不能存储数组。我的对象看起来像这样:

I have created an app using ionic and cordova and now I want to remake it on iOS. I am working with iOS for the first time, and I cannot figure out how to store data. For example: I have a form where user has to input some data, but the inputs are not in one view, there must be several views. I used to create empty array and just put everything step by step, but now i can't use same view controller on multiple views. Tried to do it with core data, but core data cannot store arrays. My object would look something like this:

var sampleArray = (
duration: 13,
dayOfTheWeek: Thursday,
personList: [
  (name: Rocky,
   age: 26),
  (name: Ralph,
   age:23)
  ]
)

问题是:我如何制作一个输入表格,视图和我应该在哪里存储数据,以后我可以将所有数据存储到核心数据中?

The question would be: How could I make an input form which would be on several views and where should I store the data, and later I would be able to store all the data into core data?

推荐答案

As第一条评论说,你的问题非常大。
当你说'几个视图中的一个表单'时,我认为它是'每个视图的一个表单'。
保持简单S ...;)
(除非您对表单使用页面控制。)

As the first comment says, your question is quite large. When you say 'one form on several view', I consider it as 'one form per view'. Keep It Simple S... ;) (Except if you use page control for your form.)

基本上,您有三种方式存储数据:

Basically, you have three ways to store data :


  • NSUserDefaults:
    将数据存储在字典中供以后使用

  • 文件:
    将数据保存到文件中(为什么不.csv之类的?)

  • CoreData:
    您可以将数组作为二进制数据保存在Core Data中

这些主题有很多教程。
www.raywenderlich.com 网站是一个很好的开始......

There are numerous tutorials on these topics. www.raywenderlich.com site is a good one to begin...

这篇关于建议在哪里存储iOS应用程序的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆