0

I'm trying to build a simple to-do list app with Swift 3 and Xcode 8. It includes a text input box, a submit button, and a table, where each cell includes a title and a subtitle that shows the date. So far, all of this has worked.

Currently, I'm trying to get it to save when I leave the app. I've tried user defaults (which I have succesfully used in the past, but wasn't working for this), core data (which seemed like a lot of excess code, will do if I have to), and a JSON file I tried to read and write from with SwiftyJSON (have also succesfully used this). None of these have worked.

What would be the simplest/best way to solve my problem?

Thank you!

4

2 回答 2

0

您可以将数据保存到:userdefaults、documents 文件夹中的文件、coredata、SQLite db、第三方领域。您也可以发送到您的远程服务器。

于 2017-01-20T02:28:07.067 回答
0

在这些情况下,在本地保存数据的最简单方法可能是使用NSCoding。请参阅 Apple 的开始开发 iOS 应用程序 (Swift)指南中的“持久数据”部分。

您可能还想查看 Apple 的示例代码Lister(适用于 watchOS、iOS 和 OS X),它演示了适用于 iOS 和 OS X 的生产力应用程序,使您能够跨设备创建和共享待办事项列表。用户可以在本地或 iCloud 中存储他们的文档,但这可能超出您的用例所需。

于 2017-01-20T03:47:24.653 回答