I am learning Core Data and want to create a data base with 10000 data. what is the easier way to input these data to a database and read them to Core Data?
Asked
Active
Viewed 2,091 times
1
-
http://stackoverflow.com/a/9109728/265167 – Yaqub Ahmad Mar 08 '12 at 12:25
3 Answers
1
Here is a good tutorial by Jeff Lamarche on how to seed Core Data. In a few words: you have to parse some data source (plist, sqlite, ...) and store it in Core Data.

sch
- 27,436
- 3
- 68
- 83
-
-
@user1232250 - It depends on the size of each item in your data. If you have performance issues with plist, you can use sqlite instead. – sch Mar 08 '12 at 11:08
-
-
Importing data to an sqlite db that holds managed objects should be carried out with extreme care. MO framework stores also metadata in sqlite tables that could be difficult to fill out in the correct way. I don't recommend this path except when you want to refill a db once exported from a MO db, and only for testing purposes. – MrTJ Mar 08 '12 at 11:18
-
So, how do I input to Core Data then? Can I input to Excel and pass to Core data to read or otherwise I need to code 10000 data in xcode? Please give me some direction. I am bit confused. Thanks for help. – user1232250 Mar 09 '12 at 12:07
0
another way is using sqlite database browser 2. it is free and you can download from surceforge!
after that you import the sqlite database wich core data has created. then you can see your entities and their attributes in tables. afterward inserting the information into tables would be easy!

Hashem Aboonajmi
- 13,077
- 8
- 66
- 75
0
No magic here: you write a cycle that iterates through your data source, create a managed object for each data item and save it with Core Data.

MrTJ
- 13,064
- 4
- 41
- 63
-
-
if you do YOUR memory management correctly it should be no problem. CoreData-framework can care for itself. Use ARC for best results :) – Martin Ullrich Mar 08 '12 at 11:12
-
`insertNewObjectForEntityForName:inManagedObjectContext:` returns to you an autoreleased object. If you're concerned about the memory consumption, you could call say in every 100 or 1000 cycle an autorelease pool drain thus you free your autorelease objects. Obviously you need to save the core data context before doing this. Have a look at the example here: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html – MrTJ Mar 08 '12 at 11:13
-
Actually, my question is how to input and store my 10000 data manually to a file or database. Should I use SQLite ? or how? – user1232250 Mar 08 '12 at 11:18
-
Basically there are three main approaches on iOS to store data in an organized way: SQLite, Managed Objects or NSCoding. To decide which to use you could read this post: http://stackoverflow.com/questions/9569466/nscoding-vs-core-data/9570385#9570385 Then here's a tutorial for SQLite: http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/ one for Core Data: https://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/iPhoneCoreData01/Articles/03_ManagedObject.html – MrTJ Mar 08 '12 at 11:52
-
And for NSCoding: http://www.raywenderlich.com/1914/how-to-save-your-app-data-with-nscoding-and-nsfilemanager – MrTJ Mar 08 '12 at 11:52