I have been reading and learning a lot about sqlite & core data for the past few days, and I just can't grasp which method is better for my app? I would prefer to use Core Data because I worked through the Stanford courses on it, and feel like I understand that better. But it also seems like it's not possible to do what I want to do with my app by just using Core Data.
Basically, I'm attempting to mock the system that Twitter uses. What I mean is that users sign up, create a profile, and when they post things, their friends see it in a feed.
Is it possible to create a system like this among a large user base by simply using Core Data? Or do I need to use both Core Data & SQLite?
Thanks!
To create a shared system like that, you will need a service in the cloud that the devices connect to.
The devices would have to pull data from the cloud service with local storage - especially if you want the data to be visible or usable while they are disconnected. Local storage can also provide better performance.
Concerning CoreData vs SqlLite - CoreData is for iOS only but it gets you going faster and keeps you productive with a nice designer and a nice set of APIs. SqlLite is much lower level giving you direct sql control over your storage and queries. It's certainly possible to write local storage for something like your describing in sqlite or core data.
The other consideration is whether you want to share that storage code (schema/queries/etc...) across other platforms eventually like Windows Phone, Android, etc... Sqllite is cross platform and works great on devices and desktops. In some scenarios, the store it self (the data file) could be portable across devices platforms.
Depending on the complexity of your storage and whether you want to share some of that across devices or just code separately is a consideration. There is no one right answer here.
Related
I am currently creating a macOs application that stores customer data in a CoreData database.
Now I want that data to be stored in the iCloud. The idea is that every user has its own data in his iCloud. If he uses more than one Mac/iOS device he can access his data.
So I don't a centralized data storage for all customers but a data store for each customer separately.
I have read through some topics regarding CloudKit but was confused about it in general:
CloudKit provides a data storage for global data (e.g. I want to store data of customer)
Is there a possibility to story CoreData to an iCloud account of every customer?
If so is this possible by CloudKit or do I have to use a third party lib like Ensembles? (That mentioned there was a thread of 2016 saying that Apple dismissed the possiblity to use CoreData via iCloud but only 3rd party libs like Ensemble would work now)
Can someone give me his experience in this?
Thank you
CloudKit is quite extensive. It provides three types of database:
Public, which can be shared by everyone.
Private, which is specific to one iCloud account.
Shared, which is someone's private database, but which you have been given access to.
This gives you plenty of options, and the case you are asking about, where data is shared between the devices of a single iCloud user, fits nicely into the private database. In other words, CloudKit would work very well for you.
As others have already stated, CloudKit provides you the online storage you need to move data between devices, but it doesn't provide a complete mechanism for that. That is where frameworks like Ensembles come in; they are built on top of CloudKit and other services to handle all the bookkeeping involved in keeping two devices separated in time and space in sync. (Disclaimer: I am the developer of the Ensembles framework.)
You don't have to use a framework like Ensembles; you can just communicate with CloudKit directly, but you should not underestimate how much time and skill it would take to develop a fully syncing app with Core Data. Depending on your dataset, there can be a lot of gotchas. Ensembles and similar frameworks do a lot for you:
Ensuring changes are played back in the same order on every device
Handling concurrent changes on two different devices
Removing old and redundant data
Keeping memory usage low by providing batching, which is very important on iOS
In short, you can do it yourself, but I wouldn't recommend it. If you want Core Data sync, I recommend Ensembles, or to look at other libraries like Seam (I have not used this, but it seems popular).
If you are not married to Core Data, you could look at options like Realm and Firebase, which effectively handle the sync problem and the client API in one hit.
I have a rather simple idea for an iPhone app. What I need to accomplish:
Allow login of users (which means I'll have to store usernames, passwords, and other account info).
Allow users to submit strings that other users can view.
Attributes attached to each string that must be tracked (i.e. "votes, views, comments, etc.).
As such, I assume I'll need to start learning about databases and working between a server and client. I've gotten my feet wet in OSX/iOS programming (specifically Objective-C) before. I want to learn how one can accomplish a data-based application and the needs I listed above.
I've done some light research and discovered something called SQLite (free and open-source is always good). Is this the right path to achieve what I want to do? I'm a total "noob" when it comes to this field of server/client/data "stuff".
Your help is greatly appreciated.
SQLLite is more like a local database. Really, the database that you will use is unimportant. It sounds like a project with webservices. Inside your webservices, you might connect to a Microsoft SQL Server or anything you want.
I think you should study how to setup a webservice that can be accessed in your code. Webservices is not an Objective-C topic, it applies to any platform. Your project is more like a web development project.
You can save user's credentials in keychain.
#Kinderchocolate is right about introducing database into your project.
It hears about a app which need transmitting data among clients.It means your need server database and local database.
For server database,I recommend you to use Parse.Parse is a platform which provide a convenient way to use their server database with Objective-c in your app.This tool will save many times and energy(it's not necessary to learn PHP,Apache,Mysql).Parse is not free of course,but it has a free period and enough for you to examine your idea.
Here's Parse!.
For local database,I recommend you to use Core Data,Which is provided by XCode.Core data is so strong to meet your need.You can find a way to use Core Data in many books.
Go try Firebase for database in the cloud. (On the server). In Swift 4 there is complete support for Firebase and SQLite
I've been researching now for couple of days about this matter but with no luck.
I am learning iOS development with the plan of developing iPhone app mainly. Now this app will mimic the behaviour of my PHP site.
The question: Can I interact from my iPhone app directly with my tables to load and/or insert new data? if not mySQL then which database is used to host the data for CRUD operations? JSON objects? if yes, then how?
As you can see I am really unaware of the way and hope that some light should be shed on storing and retreving data from existing database or what I need to host new database to use with iPhone.
The "best" and easiest way (for me anyway) is to use CoreData.
CoreData is a data management system. You set up some objects and relationships in it and then interact with those (use fetch requests to retrieve them and stuff).
CoreData then manages a datastore (most often a SQLite DB) which it uses to store the objects and relationships etc...
Using CoreData removes the necessity of a DBA and a lot of the complex DB logic and stuff.
A good tutorial to look at is this one...
http://mobile.tutsplus.com/tutorials/iphone/iphone-core-data/
I bought this book though...
http://www.amazon.co.uk/Pro-Core-Data-Professional-Apress/dp/1430236566/ref=sr_1_2?s=books&ie=UTF8&qid=1358773284&sr=1-2
and found it extremely useful for everything from starting out to the more advanced stuff.
When used properly, CoreData makes it VERY easy to use and manipulate persistent data.
YES, You can interact from your iPhone app directly with your tables to load and/or insert new data; Check the next tutorial - interact with your MySQL/PHP server http://www.scott-sherwood.com/ios-5-uistoryboards-a-practical-example/
CoreData is good but limits to access to just iDevices.
I use couchdb, means a copy is stored in the cloud with auto syncing between cloud and devices allowing for web updates and also Android
I am new to iPhone app development and have a question about storing data. I've spent quite sometime learning about core data but still confused about the concept of persistence store.
What I understand is that core data is just a way of managing the data you downloaded from an external database. But given that core data is backed by SQLite, does that mean there exists a SQLite db in-memory while running? If so, does that mean when I use core data it will be more effective if I download a huge data set at start? But what about apps such as twitter or Facebook that require constant update of data, is a straight $NSURLConnection$ sufficient in these cases? If core data is used, will the extra overheads (i.e. data objects) be of any burden for such frequent request of update?
I would also like to find out some common ways of setting up an online database for iPhone app? Is it usually MySQL servers with a homemade Python wrapper that translates the data into JSON? Any standard server provider would provide the whole package? Or open source code?
Many many thanks!
I'm going to go through and try to address each of your questions, let me know if I missed one!
Firstly, Core Data can be used to store information generated in your app as well, there is nothing keeping you from using it in one way or another.
The way I understand it working is that the file, or other storage mechanism Core Data uses, exists regardless of whether or not your app is running. For a user to have to wait for a large database to be downloaded and loaded into a local database without being able to interact with your application is not the best way to do it in my opinion, people react negatively unresponsive UI. When a user may run your app for the first time, its possible you may need to get a larger set of data, but if any of it is generic and can be preloaded that is ideal, the rest should be downloaded as the user attempts to access it.
Facebook and Twitter applications work just as you understand in that a connection is established and the information is pulled from the appropriate site, the only thing they store is profile information, as far as I know. I would hesitate to use Core Data to store peoples information as eventually yes, there would be a significant amount of overhead caused by having to store peoples news feed or messages going back months on end.
As for setting up on online database that is something I'm unfamiliar with, so hopefully someone else can provide some insight on that, or if I find something I think may be of use, I will post back here for you. This part may actually merit its own separate question.
Let me know if you need to me elaborate on anything!
So I have been doing lots of reading and found out NSCache is not persistent which is a slight problem for what I need to do. I have heard that I will need to use Core data instead... but I don't have any experience with core data so am wondering if its the only solution for persistent data.
The app will allow the user to search through a catalog, by typing in a search parameter in the code and select a distributor for their search parameter. What I want to do when the app loads is download the list of distributors and save them to a "cache" the will be persistent (till when the header I will make at some point changes and demands the app to update the cache), so that if the user turns the app of or the phone next time then open it the manufacture.
Now that I'm getting abit deeper into my app I'm getting abit lost in things for instance how would setting up a cache work with regards to NSURLConnection.
Any suggestions or code examples would be greatly appreciated..
This previous answer of mine might help you decide.
To sum it up:
If your data is small, static and low-complexity, use a collection class and write it to disk using the built-in class methods
If the data is static, low-complexity but large, SQL may be a good solution especially if you already know it.
If the data is dynamic and complex regardless of size, then Core Data is your best choice.
Viewed purely from the technical perspective, Core Data is always the best choice for iOS/MacOS API apps. Core Data is not just a persistence API, it is an API for creating the model layer of the Model-View-Controller design paradigm that the Apple API uses. It not only persist the data, but models it, validates its and provides an easy interface to the rest of the API.
If your going to be writing iOS apps, you need to eventually learn Core Data. However, it does have a learning curve and you should pick the method right now that will let you ship a usable app.
You can also check out sqlite. Here's another question that discusses getting started with sqlite on the phone: Where's the best SQLite 3 tutorial for iPhone-SDK?
The advantage to sqlite is that it is fairly easy to pick up. The downside is that you have to write queries for everything, and that can be a pain. It doesn't save objects, just data, numbers or text.