title: fetching a custom object from core data into an array
body: <p>I'm having trouble fetching my object from core data. Object looks like this: </p>
  
  <pre><code>class cilj: NSObject {
  var imeCilja: String
  var slikaCilja: String }
  </code></pre>
  
  <p>My entity is called Entity and has two Attributes "tekst" and "slika", both of type String. My save func is this: </p>
  
  <pre><code>func saveImage(goalName:String, imageName:String) {
  
    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
      let managedContext = appDelegate.managedObjectContext
  
      let entityDescription =  NSEntityDescription.entityForName("Entity", inManagedObjectContext:managedContext)
  
      let thingToSaveToCD = NSManagedObject(entity: entityDescription!, insertIntoManagedObjectContext: managedContext)
  
      thingToSaveToCD.setValue(globalGoalTitle, forKey: "tekst")
      thingToSaveToCD.setValue(globalGoalImagePath, forKey: "slika")
  
      do {
          try managedContext.save()
          print("managed to save to core data")
          //5
         // listaObjekata.append(cilj5) as! [cilj]
      } catch let error as NSError  {
          print("Could not save \(error), \(error.userInfo)")
      }
  
  }
  </code></pre>
  
  <p>I use an alertController to pick up the text, and imagePicker to pick up image that I then store in documents and get the path. I store both of these in a global variables visible in the code above.</p>
  
  <p>My fetch function is :</p>
  
  <pre><code>func coreDataFetch(){
  
      //core data fetch
  
      //1
      let appDelegate =
          UIApplication.sharedApplication().delegate as! AppDelegate
  
      let managedContext = appDelegate.managedObjectContext
  
      //2
      let fetchRequest = NSFetchRequest(entityName: "Entity")
  
  
      do {
          let fetchedResults =  try managedContext.executeFetchRequest(fetchRequest) as! [cilj]
          listaObjekata = fetchedResults
  
  
      } catch let error as NSError {
          print("Could not fetch \(error), \(error.userInfo)")
      }
  
  }
  </code></pre>
  
  <p>I have been through ray wenderlich's article on Core Data, Apple's documentation, a couple of YT videos but I still seem to be missing something. I would greatly appreciate any help. Thanks !</p>
  
  <p>EDIT - here is my cellForRowAtIndexPath</p>
  
  <pre><code> override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
  
      let cell = tableView.dequeueReusableCellWithIdentifier("myCell") as! cellController
      let ciljZaPrikaz = listaObjekata[indexPath.item]
  
      cell.labelText.text = ciljZaPrikaz.imeCilja ?? "no text found"
  
      let path = getDocumentsDirectory().stringByAppendingPathComponent(ciljZaPrikaz.slikaCilja)
      cell.imageToShow.image = UIImage(contentsOfFile: path)
  
      return cell
  }
  </code></pre>