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

Regex find and replace between <div class="customclass"> and </div> tag -

jpa - Passing entitymanager from reflection method -