Relationships between data is critical to be successful in Core Data. In this video, you'll learn how to create them in Xcode.
Watch the full series over here:
raywenderlich.com is a website focused on developing high quality programming tutorials. Our goal is to take the coolest and most challenging topics and make them easy for everyone to learn – so we can all make amazing apps.
We are also focused on developing a strong community. Our goal is to help each other reach our dreams through friendship and cooperation. As you can see below, a bunch of us have joined forces to make this happen: authors, editors, subject matter experts, app reviewers, and most importantly our amazing readers!
About Core Data (from Wikipedia)
Core Data is an object graph and persistence framework provided by Apple in the macOS and iOS operating systems. It was introduced in Mac OS X 10.4 Tiger and iOS with iPhone SDK 3.0. It allows data organised by the relational entity–attribute model to be serialized into XML, binary, or SQLite stores. The data can be manipulated using higher level objects representing entities and their relationships. Core Data manages the serialised version, providing object lifecycle and object graph management, including persistence. Core Data interfaces directly with SQLite, insulating the developer from the underlying SQL.
Just as Cocoa Bindings handle many of the duties of the controller in a model–view–controller design, Core Data handles many of the duties of the data model. Among other tasks, it handles change management, serializing to disk, memory footprint minimization and queries against the data.
Core Data owes much of its design to an early NeXT product, Enterprise Objects Framework (EOF).
EOF was specifically aimed at object-relational mapping for high-end SQL database engines such as Microsoft SQL Server and Oracle. EOF's purpose was twofold: first, to connect to the database engine and hide the implementation details; second, to read the data out of the simple relational format and translate that into a set of objects. Developers typically interacted with the objects only, which dramatically simplifies development of complex programs, at the cost of some "setup". The EOF object model was deliberately designed to make the resulting programs "document like", in that the user could edit the data locally in memory, and then write out all changes with a single Save command.
Throughout its history, EOF "contained" a number of bits of extremely useful code that were not otherwise available under NeXTSTEP/OpenStep. For instance, EOF required the ability to track which objects were "dirty" so the system could later write them out. This was presented to the developer not only as a document-like system, but also in the form of an unlimited "Undo" command stack. Many developers complained that this state management code was far too useful to be isolated in EOF, and it was later moved into the Cocoa API during the transition to Mac OS X.
Oddly, what was not translated was EOF itself. EOF was used primarily along with another OpenStep-era product, WebObjects, which was an application server originally based on Objective-C. At the time, Apple was in the process of porting WebObjects to the Java programming language, and as part of this conversion, EOF became much more difficult to use from Cocoa. Enough developers complained about this that Apple apparently decided to do something about it.
One critical realization is that the object state management system in EOF did not really have anything to do with relational databases. The same code could be, and was, used by developers to manage graphs of other objects as well. In this role, the really useful parts of EOF were those that automatically built the object sets from the raw data, and then tracked them. It is this concept, and perhaps code, that forms the basis of Core Data.
About Swift (from Wikipedia)
Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, macOS, watchOS, tvOS, and Linux. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of extant Objective-C (ObjC) code written for Apple products. Swift is intended to be more resilient to erroneous code ("safer") than Objective-C, and more concise. It is built with the LLVM compiler framework included in Xcode 6 and later and, on platforms other than Linux, uses the Objective-C runtime library, which allows C, Objective-C, C++ and Swift code to run within one program.
Swift supports the core concepts that made Objective-C flexible, notably dynamic dispatch, widespread late binding, extensible programming and similar features. These features also have well-known performance and safety trade-offs, which Swift was designed to address.