Hello CoreData!

by Viktor Amelin, Senior iOS developer

Introduction

I personally prefer the Realm, since you don’t need to do a lot of movements to make it work: simply install and begin to create all what you want, plus the official website has a great documentation for all features. But when you look through the vacancies of other companies (I personally never do it. Other companies… they exist? For real?!:)). Often you see, that CoreData is required, and if you do not have experience with this framework, then you can easily became «gone with the wind» at the beginning of the interview, and nobody well ever know all about those beautiful buttons you can do :).

Example 1

The project is available for study and called MagicalRecord_project (originally I wanted to use this framework). Let's view the Model.xcdatamodeld file:

Example 2

In this example we will create StoreManager. Open StoreManager_project project. StoreManager was created using Singleton pattern (one copy for the life of the program):

Example 3

In this example, I wanted to demonstrate how to work with JSON. Of course, in a real project I would use something for mapping, SwiftyJSON for simplicity, maybe. But for a little lesson, I requested JSON as a string and then parsed it:

enum ContextType {
case main
case background
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stfalcon.com

IT company designing custom web services and mobile apps. Our goal is to create useful and convenient software. We are the founder of the Air Alert app