iOS Core Data with Swift
Why Stack Overflow recommends it
Stack Overflow users link it when asking about or answering Core Data setup in Swift, citing it as the tutorial they followed for the context helper and entity subclass approach.
Recommended by 0 people across 0 different months, 2017 to 2017.
What it is
A near-hour-long Swift tutorial that explains how Core Data works in iOS 10, covering the framework's terminology before building a real example app. It is presented by Electronic Armory and comes with a GitHub repo of the tutorial files.
What people said
Cites Munib · 2017-01 · Stack Overflow · on “Xcode 8 Core Data Template for iOS 8,9”
Thanks to DCToDaylight's answer [LINK] . I made this file, which you can simply drag and drop. I have also made my managed object context static, and my init method private. So that someone can't accidentally instantiate a new context. The function called getContext makes it easier every time you do something with core data. The idea to create a static managedObjectContext, a separate file and the function came from this YouTube tutorial [this video] . For this example I made a new file called DatabaseController.swift and put all this code in there. This will simply make my code easier to manage and read. You can also copy from the // MARK: - Core Data stack to the bottom of the file and replace
Cites Amber Rebecca Howe · 2017-03 · Stack Overflow · on “How to make a subclass based on an entity in core data?”
I was following a few tutorials on youtube to get specific things done in my own project. This one in specific: [this video] He instructed the users to make a subclass for your entities. I did this and was hoping for the same thing he got. However, I got tons of errors...I deleted my .xcdatamodeld file and planned to do it over because I might have just done something wrong and after I deleted it, these errors went away. Not sure why that would be? Nonetheless I redid the process and made it simpler but the same exact thing happened. Here is the code that was automatically generated when I created the subclasses. for CoreDataClass file import Foundation import CoreData @objc(GeneralEvaluation) pu
Cites Luke · 2017-03 · Stack Overflow · on “How do you load attribute data from the entity into a single (1) UIViewController?”
I'm new to coding with Swift, and I've been using the tutorial from Udemy by Aaron Caines, which has been great. The tutorial he did was using a UITableViewController. I have an app that uses a single UIViewController (ONLY ONE VIEW and it's not a UITableViewController). I've already loaded CoreData into the build phases. I've been able to verify that the data is saved in the attributes, but for some reason, I can't load the data back into the two text boxes and one image view that I have in the view controller. I've placed a couple of questions as comments within the code. It should be as easy as setting up the variables: @IBOutlet var textName: UITextField! @IBOutlet var descriptionName: U
Cites Josch Hazard · 2017-06 · Stack Overflow · on “Array of structs: How to save in coredata?”
I´m trying to save an array of structs into coredata. I did a lot of research, but i cannot find the solution. Here´s what i´ve got: import Cocoa import CoreData class ViewController: NSViewController { struct StudentsStruct { let firstName: String let lastName: String let age: Int } let Studentsdata: [StudentsStruct] = [StudentsStruct(firstName: "Albert", lastName: "Miller", age: 24), StudentsStruct(firstName: "Susan", lastName: "Gordon", age: 24), StudentsStruct(firstName: "Henry", lastName: "Colbert", age: 24)] override func viewDidLoad() { super.viewDidLoad() let student: Student = NSEntityDescription.insertNewObject(forEntityName: "Student", into: DatabaseController.getContext()) as! St