As far as I know, in iOS we can keep data in JSON files, .plist or .xml files, NSUserDefaults (which is basically a .plist file), SQLite database, or Core Data (which can be set to have different data stores, but usually we use .sqlite files).
I am currently supposed to make my app be able to work with tens of thousands of records, and I am using Core Data. The thing is that my client told me Core Data is probably not the best solution for large datasets, and I am confused because as far as I know, if we have so many records we should obviously not keep them all in memory (in NSMutableArray or other collection objects), and Core Data seems to be the best and fastest way to implement all the functionality.
Please let me know if you have the same problem in the past and which solution you chose.
I have used core data for a 64 thousand object database, worked perfectly as expected. Not sure exactly what you are trying to do but core data will work fine.
Related
So I have an iOS app and this JSON file (about 50 MB) that has a deep tree structure. The goal is to store this file locally and use its content later on the app, with the possibility of updating the data or some parts of it in the future..
After some research, I found out that I can use core data, but it seems inconvenient for such complex structure.
So, I thought maybe I'll persist the data in a class object, but this may end up consuming the whole mobile memory.
Now, I'm thinking if it is plausible to store the data in a plist then map the hell out of it to present its content.
What do you think guys? Do you have any other ideas or thoughts?
Just store the JSON as you received it, as NSData. It doesn't care one bit about the structure, so you can parse it again.
After a lot of research and reflexion, I ended up using Realm for its simplicity and effectiveness.
I am going to use Core Data and SQLite together for managing big amount of data on iOS devices. Is that good solution? Are there other ways?
Sqlite can handle very large ammount of data. and core data also use sqlite in backend. SO your approach is right. You should go for this.
for more detail see this:
http://www.sqlite.org/limits.html
There are two ways in which you can write data to file in iOS.
One is NSUserDefaults and the other is Core Data.
NSUserDefaults is not the proper way for storing large amounts of data. It's used to store application settings and temporary data.
Core Data is the proper way for storing and managing large ammounts of data.
Background:
I have an app that retrieves a list of restaurants from a database, each have an individual array of basic information about them (hours, name, address, etc). I would like to retrieve that information from the server on the apps first load, but then have it stored within the app itself, with either NSUserDefaults or Core Data, since the information is unlikely to change. The max number of restaurants I would be storing is about 25, is that a small enough data collection to use NSUserDefaults?
I have looked at similar questions with storing data with over 1,000 records, but I am only storing a small array.
Question:
NSUserDefaults is much easier to use than Core Data, so if possible I would like to avoid using Core Data. In my case, will there be a performance problem if I am storing my list of restaurants in NSUserDefaults instead of Core Data?
Depends on the
size
structure of data
requirements re integrity of the data
Just an Array of 10 or 20 "restaruants" I would certainly store in NSUserDefaults. But only when I am sure that this will never become more complex. Because when you later extend your model but started off with NSUserData then you may remain with NSUserDefaults just because you avoid migrating it to Core Data during the upgrade of an installed app.
So for more complex structures including references and when you have further plans with your app towards more functionality that may require more entities, then you should go for Core Data from start.
BTW, it is not that complicated as you may think.
However, instead of abusing NSUserDefaults, you could simply write an NSArray to file using -writeToFile:atomically: and -initWithContentsOfFile: to read them in.
NSUserDefaults is not intended for data, it's for storing simple key-value pairs like user settings and flags. Core Data is a bit hard to learn at first, but definitely worth it, even for simple applications.
If it really is a small, simple data set that won't change very often, you can also store some data in a local plist (i.e. save NSArray or NSDictionary to plist using writeToFile method). This isn't very different from using NSUserDefaults in terms of performance, although I think it's cleaner and easier to manage. If it never changes you can also include the plist with your app resources in XCode by creating a plist file and filling it in with your data.
Considering the amount of the data, user default or a specific plist/json file are all good. CoreData is definitely overkilling.
I am building an application that recovers JSON data (1000-2000 lines) from a website. It's basically just a bunch of arrays and values, nothing fancy. What would be the best way to store this information and use it between the views? Should I create a local sqlite database, write to file or just send the information from view to view using prepareforsegue?
I would think the latter is faster and easier to implement, but I'm not sure if it's easier to use after (I'm new to IOS).
Thank you !
I'm using Core Data with Magical Record. It easily maps your JSON objects into NSObjects which are then persisted into Core Data. It is thread safe and very powerful.
Or you can map it yourself into NSObjects of your choice without actually persisting them or saving them anywhere which is much easier in some cases. It is a good way to go as well.
Both methods looks OK . Now it depends whether your JSON data is big enough to slow down the app.
Sqlite Database is easy to implement to store large information in your app.but if you want to increase performance of app to access data locally you can use core data to store data because it providing object relationship to store data in app that is easy to access and store data.but now it is depends on you
I am writing an iPad app that will be expandable with new items via in-app purchasing. For example, my current plan is to have a jpg pattern and a matching plist file with the parameters I need to expand that pattern into a full picture.
The user will select one jpg/png from a list of small thumbnails - the list is held in Core Data - and the app will find the matching plist for displaying the jpg/png correctly. I'll only have about 10 of these open at one time. But I could end up with storing 1000s of jpgs and plists.
Does storage of lots of small files cause app problems?
I'm going the plist way, rather than storing the parameters in Core Data, so that if I need to add parameters later, I don't have to migrate the database, just change the access in code. (And when I'm creating the patterns, it's easier to concentrate on a plist file rather than a Core Data row.)
The app seems to work really well at the moment, but I'm worried about futures...
My app does also use Core Data for other things, so I could change over if the app will get bogged down with number of files.
Thanks.
Saving a large number of small files is not a problem as long as you have a well thought out means of naming and tracking the files.
Remember that the user does not have the same flexibility and ease of file management on a mobile as they do on non-mobile platforms. Designs that work on non-mobiles are unworkable on a device used on the move with one finger.
However, when you say:
And when I'm creating the patterns,
it's easier to concentrate on a plist
file rather than a Core Data row.
... the use of "row" suggest that you haven't fully grasped Core Data's utility. Core Data doesn't use rows, columns, tables or joins. It's an object graph management system that sometimes uses SQL way behind the scenes.
Core Data is designed to handle data in a way that meshes seamlessly with the rest of the object oriented API for the UI and other services. When you use other data management systems like plist, you will most likely end up manually duplicating a lot of Core Data's functionality anyway.