简体   繁体   English

如何在我的应用程序中保存表格视图的数据?

[英]How do I save a table view's data in my app?

I created an app where you edit a table with an "activity" and set a "time" for the activity. 我创建了一个应用程序,您可以在其中编辑带有“活动”的表并为活动设置“时间”。

I want the data to be stored in the app so that when the user opens up the app again all the activities are still there. 我希望将数据存储在应用程序中,以便当用户再次打开应用程序时,所有活动仍然存在。

How do I save all that data so it's still there once the app is reopened? 如何保存所有这些数据,以便在重新打开应用程序后这些数据仍然存在?

You need to use Coredata . 您需要使用Coredata There some great tutorials in the Internet (like this one here ) that can help you. 目前在互联网(像这样的一些伟大的教程在这里 ),可以帮助你。

You can use CoreData or SQLite . 您可以使用CoreDataSQLite But from my experience, when I came accross Realm , I was literally stunned. 但是从我的经验来看,当我遇到Realm时 ,我确实惊呆了。

Realm 领域

Realm is a replacement for SQLite & Core Data. Realm替代了SQLite和Core Data。 It can save you thousands of lines of code & weeks of work, and lets you craft amazing new user experiences. 它可以为您节省数千行代码和数周的工作,并使您可以创造出惊人的新用户体验。

It is really simple and powerfull to use, and actually way faster than CoreData. 它真的很简单并且功能强大,并且实际上比CoreData更快。 You can create a database and read/save data from it in just a couple of lines of code, in constrast of CoreData. 与CoreData相比,您只需两行代码即可创建数据库并从中读取/保存数据。

There are also lots of tutorials and a great documentation. 还有很多教程和出色的文档。

I started using Realm in every app, either bussines or free-time apps. 我开始在每个应用程序(商务或免费应用程序)中使用Realm。

You can get it here: https://realm.io/ 您可以在这里获取它: https : //realm.io/

Like the others said core data is the way to go on this, its rather simple to use but if you still don't feel comfortable with it you will need to store it in some sort of data base so that when you change/edit or add some sort of information to a users account it will stay. 就像其他人所说的那样,核心数据是解决问题的方法,它非常易于使用,但是如果您仍然不满意它,则需要将其存储在某种数据库中,以便在进行更改/编辑或向用户帐户添加某种信息,它将保留。 If that isn't enough check out NSUserDefaults! 如果还不够,请查看NSUserDefaults!

Have a good day! 祝你有美好的一天!

If the data is not too long you can use NSUserDefaults, actually this class is recommended for storing setting data or something like favorites etc.. but you can start from it. 如果数据不太长,则可以使用NSUserDefaults,实际上建议使用此类来存储设置数据或诸如“收藏夹”之类的内容。但是您可以从中开始。

Now if what you are planning is a huge data storage, maybe a lot of entries, lots of keys and in general a lot of DATA I strongly recommend you to use CORE DATA, there are a lot of tutorials, they are even books about core data so you need to do a lot of research. 现在,如果您计划的是巨大的数据存储,也许有很多条目,很多键以及一般来说很多数据,那么我强烈建议您使用CORE DATA,这里有很多教程,它们甚至是关于核心的书数据,因此您需要进行大量研究。

And a combination of both I think, It could be Parse this service could help you not only with local storage, you can start a free remote storage with plenty of space and request to begin with your tests.... 我认为,两者结合起来,可能是解析此服务不仅可以帮助您使用本地存储,还可以启动具有足够空间的免费远程存储并请求开始测试。

Here you have a local Parse DataBase loaded into an UITableview's 在这里,您将本地解析数据库加载到UITableview的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM