I am working on a to-do list app in Xcode. So what I want to do now is after I close the app and reopen it, I want to see the lists I created before I close it. I think this is about memory keeping of the app. So what can I do to save the lists I create and make it seen after I reopen the app later?
Asked
Active
Viewed 683 times
1 Answers
4
When your application closes the Operating system marks that memory as un used so there is no way to "keep the memory" what you can do is save them to a file. IE when you create or update an item you write that to disk and update it accordingly. This way when the application loads you can read from the file and load the saved todo items.
Quick google brought me this Objective-C answer
I hope this helps you

dbarnes
- 1,803
- 3
- 17
- 31
-
1Note that you can use a number of persistence tools, like CoreData, SQLite, CloudKit, 3rd party SDKs, etc to store the todo list. A file is probably the simplest option though. – MaxGabriel Jan 10 '15 at 01:10
-
Can you explain this more specifically? How to create a file and what to do after that? – Vincent Chow Jan 11 '15 at 10:24
-
@VincentChow what do you mean more specifically? My Objective-C is very rusty I can write out pseudo code for you but it may be more confusing. maybe http://iosdevelopertips.com/data-file-management/read-and-write-nsarray-nsdictionary-and-nsset-to-a-file.html can help. just read the array in on load and update that array as you please. Then save the array on close. – dbarnes Jan 11 '15 at 16:40
-
Yea, I have read the document and I think I roughly know how to do. I am wondering if I need to create both a .h and a .m file or just .m file. Also, if I use the method that is provided, all the objects can be stored right? – Vincent Chow Jan 12 '15 at 01:32
-
Hmm I don't know too much about objective-c but if it's anything like C/C++ you will need a .h file to have a reference to what functions exist in that .m file. As for using the method it all comes down to how you save the information. Since you are new I'd recommend json https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSJSONSerialization_Class/index.html but what you should see when you save the file is all your todo items in the file in an easy to read format. – dbarnes Jan 12 '15 at 01:40
-
okay, I know. I am wondering why I can't save NSDictionary with skshapenode being its values. I think NSUserDefault can save NSDictionary. Why can't it save it with values of SKShapenode. And how can I do that? – Vincent Chow Jan 12 '15 at 03:18
-
@VincentChow that will have to be a different question since the answer is out of scope of this question and my skill set. :P – dbarnes Jan 12 '15 at 03:23
-
Thats fine. Thanks a lot! – Vincent Chow Jan 12 '15 at 04:18