I have two tables in sqlite:
The code was generated by XCode Generation:
class Event: NSManagedObject {
@NSManaged var startDate: NSDate
@NSManaged var details: EventDetail //i think this property shoud be var details Array<EventDetail> am i correct?
}
class EventDetail: NSManagedObject {
@NSManaged var title: String
@NSManaged var location: String
@NSManaged var note: String
@NSManaged var endDate: NSDate
@NSManaged var event: NSManagedObject
}
I want to put the events in section and the eventDetails in rows.
I created the method to load events:
var eventList : Array<AnyObject> = []
func loadEvents(){
let appDel : AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let moc: NSManagedObjectContext = appDel.managedObjectContext!
let eventMO = NSFetchRequest(entityName: "Event")
eventMO.returnsObjectsAsFaults = false
var err : NSErrorPointer = nil
eventList = moc.executeFetchRequest(eventMO, error: err)!
self.tblEvento.reloadData()
}
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
return eventList.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//return (eventList[section] as Event).details.count
return //????? what can i put here
}
I don't know what can i put in the method numbertOfRowsInSection to define the number of rows the section have. Because i can't access the details.count or something liked this.
I think there is other way to do this. I saw something as use NSFetchedResultsController but without sucess.
I would aprecciate some help.