Reputation: 329
I am from Hong Kong and new in iphone programming. I know the basics of Objective-C. Now, I want to write an iOS app with about 10000 data, each item storing different information, e.g., item number,, name, color, size, etc.
For example:
Item 1 Apple Red Fruit 2, 100
Item 2 Orange Orange Fruit 3, 200
Item 3 Pork Pink Meat 3, 300
Item 4 ....... ...
Item 10000 ....
In the past if I wrote programme in desktop (PC), I would store these data in a text file (.txt) and read and write all these 10000 data to a array and then do some sorting, calcualtion etc. No memory problem and the programme run quite fast too.
However, I know that because iphone memory is limited. I have the following questions :
If I use text file to store these 10000 data and then pass these data to an array, will error be occured in iphone? or any memory problem?
Is Core Data my best alternative? Can I do sorting, searching etc. from Core Data
Is Core Data a good choice in my case?
Upvotes: 0
Views: 185
Reputation: 45200
If I use text file to store these 10000 data and then pass these data to an array, will error be occured in iphone? or any memory problem?
Yes, the application may be terminated because of memory warning. If you read 10000 file and then you will try to put it to single NSArray
object, it can have bad consequences.
Is Core Data my best alternative? Can I do sorting, searching etc. from Core Data
Yes. There are many sorting and searching methods with Core Data. Read NSFetchRequest Class Reference for more info.
Is Core Data a good choice in my case?
Definetly yes. There is no installation or storing problems, because it's built-in into iOS. See Core Data Programming Guide for more information about building an application using this powerful framework.
Upvotes: 1
Reputation: 101
Probably best to store you data in a sqlite database although core data is a possibility as well. Included a couple relevant links to get you going.
http://www.raywenderlich.com/902/sqlite-101-for-iphone-developers-creating-and-scripting
http://www.raywenderlich.com/934/core-data-tutorial-getting-started
Upvotes: 0