3 Steps to fetch in Core Data (Swift)

1. Get the managed context:

    let managedObjectContext = (NSApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext!

//Change AppDelegate for the name of the class of your Application Delegate

 

2. Set a variable to store the data:

    var contentsOfTransactionFetchRequest = []

3. Fetch the data you need

        let fetchRequest = NSFetchRequest(entityName: “Whatever”)

        contentsOfTransactionFetchRequest = try! managedObjectContext.executeFetchRequest(fetchRequest)

Hope it helps, for me it’s good to have it summarized for later reference!

If you have any feedback I’m at @MarcMasVi

Marc