Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. var first = [String]()
  2. var last = [Double]()
  3.  
  4. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
  5. {
  6. let request = NSFetchRequest <NSFetchRequestResult> (entityName : "EXPENSEAMOUNT_TABLE")
  7. request.returnsObjectsAsFaults = false
  8.  
  9. do {
  10. let result = try self.context.fetch(request)
  11.  
  12. if (result.count > 0) {
  13. for index in 0 ..< result.count
  14. {
  15. let person = result[index] as! NSManagedObject
  16.  
  17. last [index] = person.value(forKey : "expenseAmount") as! Double //ERROR fire here
  18. first [index] = person.value(forKey: "expenseAccountCode") as! String
  19. // let second = person.value(forKey: "expenseDate") // I hide this because I don't know how to save the date into an array ?
  20.  
  21. }
  22. }
  23.  
  24. } catch {
  25. let fetchError = error as NSError
  26. print(fetchError)
  27. }
  28.  
  29. var cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! customeCell
  30. cell.dateText.text = first[indexPath.row]
  31. cell.amountText.text = String (last[indexPath.row])
  32.  
  33.  
  34. return cell
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement