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

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -