ios - How can I get number of objects in section, NSFetchedResultsController Swift -


how can number of objects in section of nsfetchedresultccontroller in swift?

    if let s = self.fetchedresultscontroller?.sections as? nsfetchedresultssectioninfo {      } 

is giving me cannot downcast '[anyobject]' non-@objc protocol type nsfetchedresultssectioninfo

 var d = self.fetchedresultscontroller?.sections[section].numberofobjects 

gives me does not have member named 'subscript'

you need cast self.fetchedresultscontroller?.sections array of nsfetchedresultssectioninfo objects:

if let s = self.fetchedresultscontroller?.sections as? [nsfetchedresultssectioninfo] 

then can pass section subscript , number of objects:

if let s = self.fetchedresultscontroller?.sections as? [nsfetchedresultssectioninfo] {     d = s[section].numberofobjects } 

Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -