iOS Core Data in Swift 3 and iOS 10
***** Created with Xcode 8 and Swift 3 *****
Published: September 2016
This course was created for Core Data using Xcode 8 with Swift 3. If your project is dealing with older version of Core Data in iOS 9 or prior, and you intend to learn the previous version, my other course Mastering iOS Core Data with Swift is the course you want, which was created using Xcode 7 and Swift 2.2.
What is Core Data? Why should I know about Core Data?
Core Data is one of the most powerful framework that Apple has provided for developer. "Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence." - Source from Apple".
If you are passionate about learning mobile development for iOS and looking to take your iOS development skills to the next level, Core Data framework should be at the top of your list.
By the time you are done with Core Data in Swift 3 and iOS 10 course, you will be ready and very confident to take on any Core Data project coming your way. On top of that, you will be one step closer to become a well rounded iOS developer.
What's in it for me?
In this course I will take you on a journey in the world of Core Data. We will cover all the important aspects of Core Data:
Throughout this course we will look in detail the Core Data framework to provide data storage functionality in iOS applications. We will start by creating a simple app that is utilizing Core Data framework, building our own Core Data stack and eventually using all different Core Data features into our application.
Performance Tuning and Best Practices
We will cover the various ways on fetching our data and how to efficiently using Core Data in our app. Unit testing and performance tuning will be an important part on how we can monitor our app performance in conjunction with Core Data in our application.
Along with Core Data versioning, migration and iCloud integration, I will take you on developing 5 iOS applications and how we can integrate all of these components into Core Data.
Do at your own pace
Lots of students have different methods of learning. Through out this course I will provide both the starter and final Xcode project solution, so you can either follow along one step at a time or you can jump directly to the final solution. And by the end of this Core Data in Swift 3 and iOS 10 course, you should be comfortable and ready to integrate Core Data framework in your application.
Target Audience: All iOS developer that would like to take their skills to the next level.
What are the requirements?
We will build our first single view application that will layout the foundation for the introduction to Core Data. The app will be created with built-in Core Data stack integrated with it and ready for implementation.
We will start creating our first entity in Core Data and use the KVC (key-value-coding) approach in accessing our Core Data entity/attributes. By the end of this lecture, students will be able to create Core Data application by storing and retrieving the data using key - value approach.
Solution source codes for Core Data with Key Value Coding
This is the first of many major steps in Core Data. In this lecture students will start subclassing the Entities from the data model to create Swift objects to represent the entities. This allows Xcode to provide code completion using dot notation to access our objects instead of using key - value approach.
We will learn for the first time to use Swift 3 and new Core Data syntax and the new Persistent Container.
Solution source codes for Creating ManagedObject Subclass.
We will review the concept of new Core Data stack in iOS 10.
We will review in more detail how the Core Data stack has evolved from iOS 9 to iOS 10.
In this lecture will cover how to extract Core Data stack out of AppDelegate. Students will create a regular Single View Application without checking the option for Core Data during the project creation, and instead will work toward building the Core Data stack manually as a separate Swift file.
Solution source codes for Core Data Stack Implementation.
Some projects may have been created without Core Data and as the projects evolve, there comes a need to utilize Core Data for data persistent. There is no need to start the project from scratch, we will learn how to 'inject' the Core Data stack into the existing projects.
This lecture introduces how to set the entities and their attributes in Core Data. It shows different data types available in Core Data that can be assigned to attributes, such as String, Integer 16, Double, Binary Data. We will learn about:
Xcode project source codes for Entities, Attributes, Relationship and Object Inheritance
We will look into parsing a json format data and store the extracted information into the Core Data with sqlite backend.
Xcode project solution source codes for Handling JSON Data
We will check some development tools that will us to actually see the data in the Core Data sqlite backend.
We will learn how to implement a batch delete in dealing with multiple records removal. This will improve the app performance tremendously in large data sets scenario.
Xcode project solution source codes for Multiple Records Removal
We will learn the fundamental concept of searching records in Core Data using predicate. We will be using the new Swift 3 and Core Data syntax and functions in iOS 10 to retrieve our data.
In this lecture we start diving in building the request object and using predicate to set the search criteria. We will look into the following topic:
Xcode project source codes for Records Searching
We will explore how to handle the request within a one-to-many relationships.
Xcode project solution source codes for Fetch One-To-Many Records
We will be working on filter and sort functions of the Home Report app and how to update the records in table view using protocol-delegate approach based on the sort and filter options selected by end users.
We are introducing CompoundPredicate to handle multiple criteria when submitting a query to Core Data. We will use CompoundPredicate and SortDescriptor to build the request object.
Xcode project source codes for Sort and CompoundPredicate
This lecture shows how to utilize Core Data aggregate function "SUM" and "COUNT". It demonstrates the use of DictionaryResultType, CountResultType and CountForFetchRequest. It also shows how to build the expression description into the request object to execute Core Data aggregate functions.
On this second part of Aggregate function lectures, we will look into using Core Data MIN, MAX and AVERAGE aggregate functions.
This lecture introduces asynchronous fetching in Core Data using NSAsynchronousFetchRequest and how to handle the response in completion handler.
Xcode project source codes for Asynchronous Request
One of the newest features of Core Data in iOS 10 is to automatically generate the managed object subclass and we will be exploring on how to set this up in Xcode 8.
Xcode project source codes for Automatic ManagedObject Subclass Generation.
This is another automatic generation feature in Xcode 8. The difference with subclass generation, we will only set the automatic generation for the class extension. We would explore on how and what to generate and what still needs to be created manually.
Xcode project source codes for Automatic Class Extension Generation.
We will demonstrate how to use NSFetchedResultsController to fetch data from Core Data store. NSFetchedResultsController is created to support tableview in mind so it is a perfect fetching approach when we are using UITableViewController. We will look into more detail why this fetching strategy brings benefit to display and update data in the tableview on the subsequent lectures.
Xcode project source codes for Tableview with NSFetchedResultsController.
This lecture demonstrates how to delete a record from our Core Data data store by utilizing NSFetchedResultsController to perform the object deletion. It shows how effectively NSFetchedResultsController handles the update for tableview datasource without the need to manually reload the data.
Xcode project source codes for Delete a Record.
We will look into updating multiple records with one batch request. One hidden challenge on this lecture is to update the view after the batch update request is executed. To address this, we will look to fault object and how we can get the object out of it and update the state of the object. We will also learn how to prevent the cache data being used instead of the updated object state.
Xcode project source codes for Batch Update.
This lecture will show how to group and cache the results from Core Data store by leveraging the attributes within NSFetchedResultsController.
Xcode project source codes for Results Grouping and Caching.
This lecture will introduce us to Xcode Memory Debugging and Core Data Profiler. We will inspect the application memory footprint and how the different approach of Core Data implementation can impact the performance of our application. We will look into how to efficiently deal with large images and how to use thumbnail when necessary will bring performance impact to the application.
Xcode project source codes for Dealing with Large Images.
We are going to implement batch size fetching to limit the number of records requested from Core Data store to improve the application performance. It is on demand fetching.
Xcode project source codes for Incremental Fetching.
We are going to implement different fetching strategy to improve our application performance. We will be using unit testing to compare the application performance on before and after tuning up our codes
Xcode project source codes for Measuring Performance.
Core Data lightweight migration is the easiest of migrating our data model. We will take advantage of new Core Data feature in iOS 10, automatic lightweight migration.
Xcode project source codes for Automatic Lightweight Migration.
This is the first part of manual migration topic. We are going to refactor our data model entities, attributes and relationships. We will create our new mapping model and learn how to manually map the old entities, attributes and relationships to the new data model.
This is the second part of manual migration topic. We are going to update our codes to reflect the new data model that we created on the first part.
Solution source codes for Data Migration with Mapping Model.
We will learn about the new background context provided in the new Core Data
Solution source codes for New CoreData Background Process
We will look into managing the managedObjectContext thread using perform block/andWait approach.
Solution source codes for Managing Thread
A walkthrough on how to sign up for Apple Developer Program.
This is not the end of the road. Set your brand new and shiny skills to work on your next Core Data projects.
Grocery List app with CRUD and Sort functionalities using NSFetchedResultsController.
Hi! I am Andi. I have a degree in MS Information Systems and been working for a Fortune Top 25 Company for the last few years.
I am passionate about mobile development and have been using both the hybrid and native approach on my projects. I fell in love with Swift and been part of the early adopter. I truly believe Swift will become one of the development languages of the future.
I live in beautiful state of Colorado in the United States and while I am not busy coding, I enjoy biking and skiing.
My motto is never stop learning and share the knowledge. Having said that, I am ready to take you on the journey of Swift development world and hope you will be a part of it.