ios - today extension, table cells not showing -
i have been writing today extension app, , have loading main apps core data database. seems working fine, can see core data information being loaded, i'm not getting cells displayed
the code have
override func numberofsectionsintableview(tableview: uitableview) -> int { return self.fetchedresultscontroller.sections!.count } override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { let sectioninfo = self.fetchedresultscontroller.sections![section] nsfetchedresultssectioninfo return sectioninfo.numberofobjects } var fetchedresultscontroller: nsfetchedresultscontroller { if _fetchedresultscontroller != nil { return _fetchedresultscontroller! } var instance = singleton.sharedinstance let fetchrequest = nsfetchrequest() // edit entity name appropriate. let entity = nsentitydescription.entityforname("medicine", inmanagedobjectcontext: instance.moc) fetchrequest.entity = entity // edit sort key appropriate. let sortdescriptor = nssortdescriptor(key: "active", ascending: false) let sortdescriptors = [sortdescriptor] fetchrequest.sortdescriptors = [sortdescriptor] // edit section name key path , cache name if appropriate. // nil section name key path means "no sections". let afetchedresultscontroller = nsfetchedresultscontroller(fetchrequest: fetchrequest, managedobjectcontext: instance.moc, sectionnamekeypath: nil, cachename:nil) afetchedresultscontroller.delegate = self _fetchedresultscontroller = afetchedresultscontroller var error: nserror? = nil if !_fetchedresultscontroller!.performfetch(&error) { abort() } return _fetchedresultscontroller! } var _fetchedresultscontroller: nsfetchedresultscontroller? = nil override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) uitableviewcell var med : medicine = self.fetchedresultscontroller.objectatindexpath(indexpath) medicine nslog("med: %@" , med.name) cell.textlabel?.text = med.name cell.detailtextlabel?.text = "next due: " + med.nextduedate() return cell }
the result nslogs in cellforrowatindex path results in
2014-09-23 00:14:34.663 medicine tracker 2[17360:1173272] moc created
2014-09-23 00:14:34.940 medicine tracker 2[17360:1173272] med: med
2014-09-23 00:14:34.955 medicine tracker 2[17360:1173272] med: trdt
2014-09-23 00:14:34.963 medicine tracker 2[17360:1173272] med: jfthm
2014-09-23 00:14:34.972 medicine tracker 2[17360:1173272] med: te
2014-09-23 00:14:34.983 medicine tracker 2[17360:1173272] med: sf
2014-09-23 00:14:34.999 medicine tracker 2[17360:1173272] med: t
so know data being loaded
Comments
Post a Comment