Looping Core Data Objects outside a Table/ Collection View
<p>I want to loop through the objects in CoreData without using a tableView or CollectionView... But using a ViewController</p>

<p>I tried something like: </p>

<pre><code>for var i = 0; i &lt; numberOfExerciseItems; i++ {          
  let exerciseItemsfromDay = fetchedResultController.objectAtIndexPath(i) as! ExerciseItemModel
}
</code></pre>

<p>This obviously doesn't work since it is not of <code>NSIndexPath</code> type as you'd get in a table or CollectionView. Are there ways to do this outside a Table / Collection View? Thanks for the ideas in advance.</p>

<p><strong>Edit</strong>
From this answer, I'd want to access an entity from an item in the items array in the loop : </p>

<pre><code>let request = NSFetchRequest(entityName: "ExerciseItemModel")
let items = (try? context.executeFetchRequest(request)) as? [ExerciseItemModel] ?? []

In this loop 
items.forEach {
    print(items) //Displays all the objects in the console. 
    print(items[1].attribute //Throws the error Value of type'AnyObject' has no member 'attribute' and I cannot access an attribute from the items array . Not sure why!

}
</code></pre>

<p><strong>Edit</strong> My ExerciseModel Class</p>

<pre><code>import Foundation
import CoreData

    @objc(ExerciseItemModel)
    class ExerciseItemModel: NSManagedObject {

    // Insert code here to add functionality to your managed object subclass

    }

    extension ExerciseItemModel {

        @NSManaged var exerciseType: String?
        @NSManaged var exerciseName: String?
        @NSManaged var durationOrSets: String?
        @NSManaged var distanceOrReps: String?
        @NSManaged var weight: String?
        @NSManaged var backgroundImage: NSData?
        @NSManaged var dayID: String?
        @NSManaged var date: NSDate?

    }
</code></pre>