Should you store everything in CoreData? [closed] - ios

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm writing an application which uses core data, and I use it to store a reasonable amount of user generated data.
However, the app also has a few settings ... such as the users name, age.
I'm wondering if it is better practice to store setting information in CoreData, or to simply store this information in UserDefaults?

answer acording to title: no
(added: especially not large amounts of binary data)

This is really more a question for Programmers Stack Exchange, but I give it a quick go over.
Core Data is powerful, but that power comes at a cost. It adds complexity and indirection.
I think it good to think of all your model objects separately. Figure out what makes the most sense for that object. This is not to say let chaos rule, patterns make code easier to understand. I think it's not good to shoehorn something into an existing pattern, because you want everything in your app to fit the pattern.
All that said. Unless your app is storing a list of users, I think it's better to use the simpler approach of NSUserDefaults.

Core Data is a big thing, not really simple. I would rather you to think about your data model first. If its "big" enough and you think about to expand it maybe in the future i would recommend you to use core data.
Now to my personal opinion:
I'm not really a fan of Core Data. I use mostly a SQlite-Database. If you need alot more and you are a starter checkout parse.com. Its a complete backend-service in verious languages. Check it out..

If you are saving credentials or some other protected data then this is the best practice:
iOS: How to store username/password within an app?
For temp data and most of other flat data use UserDefaults...
Use CoreData as more structural data storage, when you have lots of records or linked records, for more complex data structures in general...

Related

IOS Backend for User Data [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 months ago.
Improve this question
I am brand new to ios development and am looking for some advice on the best way to structure my user data and access it throughout my app.
Data is retrieved via HTTPS requests that query a database for the desired information. There are separate calls for the different tables containing information of interest. The returned data is formatted as nested dictionaries where the outermost key is the column and the subsequent dictionary is key-value pairs of the index and the table value. Example:
{"column1":{"0":"value1-1", "1":"value1-2", "2":"value1-3"},"column2":{"0":"value2-1", "1":"value2-2", "2":"value2-3"}...}
My primary requirement is that I will need to be able to filter this data by the innermost values (some will be dates, some will be numbers, etc). I would like to have the data in a format that will make this simple to do and will not cause delays as there is no limit on the number of possible rows.
I have looked into reconstructing a user-specific SQLite database with the information and querying that throughout the app as necessary. I have also explored dataframes as this app was originally developed in python - don't ask - and relied on pandas dataframes.
I know this decision will impact me heavily and am trying to do my best to make an informed decision. I appreciate any feedback and am happy to give more useful context that might be missing.
TIA
You can use SQLite database for persistent storage. This is ideal for your main requirement of filtering the data. You should also create a structure or a class modelled on your data to store and use during runtime. You can refer this for deciding between a class or structure.

Store data frame each day [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I make an application which receives data via bluetooth. I would like to store this data received at regular intervals to make a history and store it in the application.
I would like to know what to use (Core Data, UserDefaults, ...) ?
Thanks
It depends on amount of data but mostly what you want to do with that data.
Core data will take most of time to implement but you can do a whole lot of things with that data. You can search and filter items for instance by date and even put them into sections. NSFetchedResultsController can be very helpful here.
User defaults are probably not very appropriate as they are designed to hold small (or at least finite) amount of data variables like some settings, flags...
The other that comes to mind is simply saving them into file. Probably the easiest would be using JSON. JSONSerialization should be able to encode or decode your data from concrete objects to Data and back. Also there are some nice tools now that can greatly speed up the process. Check into Codable. Data in the end can be saved directly into files which may then be created in documents directory of your application.
You should evaluate how will these data be accessed. If you are targeting for instance showing charts on monthly, daily and hourly basics, have ability to remove entries and such then I would go with Core Data. If you just need to open some old logs and look into them then saving to disk is probably a more fitting solution.

Core Data vs SQLite [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am writing a trivia app in which there will be hundreds of sets of questions.
The app will come pre loaded with some quizzes however they would then need to download further quizzes which once downloaded will be stored within the app so that users can play them offline.
In this specific instance would I be better using core data or SQLite.
Thanks in advance.
The thing you have to realise here is that CoreData is not a DataBase.
It is an object persistence layer in your app. It happens to be backed by a SQLite DB by default but that's largely irrelevant.
I have written apps with a CoreData store that contains in the region of 100,000 entities and millions of relationships between them.
The argument that CoreData cannot handle complex data is not correct.
The trick is to design your Object Model exactly like you would define you object model in code.
You don't need foreign keys or join tables (these are all handled for you by Core Data).
If you have (for instance) a many-to-many relationship between Class and Student then just create a relationship between them and define it as a Many relationship on each end. Core Data will handle the data for you by creating the join tables and stuff like that. You don't need to worry about that.
For preloading the data you can also do this. It takes a bit of work but you can bundle a preloaded DB generated by CoreData and unwrap it at initial launch.
Which to use comes largely down to opinion (and so isn't a very good question for StackOverflow). There are some excellent tutorials on Core Data on the Ray Wenderlich site.
Worth reading through if you've never used CoreData before.

Should I always use Core Data for my model? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
The question is very simple.
Should I use Core Data only to persist data, to store it locally on a device or should I use it ALWAYS just to manage my application's model even if I do not persist significant amount of data?
What do you think?
Core Data provides an infrastructure for change management and for saving objects to and retrieving them from storage. It is not, though, in and of itself a database. You can use an in-memory store in your application.
Use it Always ? : NO. Use it when you think that your require the features that the Core Data framework offers to you, like any other framework.
Short answer is no. As others said if you do not need persistent store just create runtime objects and manage them.
Even when you need persistent database, Core Data is not always the best solution. For example if you have multi-platform app, or if you plan to port your application in future I'll definitely consider use base sqlite3 with requests. This way I can use same database structure in my Android, iOS and BB application, and even my sql statements will be written only once(with their interface) and then I'll just need some platform specific implementation above them.

Creating a database in Xcode [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to create a searchable database in Xcode - for example, of different trees. The database would consist of the tree name, two images, price, and a short description. What is the best and most efficient way of creating such a database?
I am aware of: Core Data, SQLite3, and Parse. I am leaning towards SQLite3 but have not found a good place to learn how to implement this. Any suggestions?
Seeing as you are new to Objective-C and I doubt this will evolve into something need direct SQL I would suggest using CoreData. Although it is not technically a data base it is an object graph, it is built for exactly what you are wanting to do. Apple was even nice enough to build wrappers for everything you want to do.
CoreData to store your tree name, two images, price, and a short description.
NSFetchedResultsController for grabbing it.
UISearchBarController for letting the user search.
You would want to use Parse if you wanted to save your data to a server. If your doing everything locally I wouldn't worry about Parse. CoreData is what you want.

Resources