ios - Could not cast value of type '__NSCFNumber' () to 'NSArray' swift -


why can't cast nscfnumber (core data) nsarray?

error:

could not cast value of type '__nscfnumber' (xxxxxxxx) 'nsarray' (xxxxxxxx).

code:

//fetch settings     func fetchaccounsetting(){         let entitydescription = nsentitydescription.entityforname("usersettings", inmanagedobjectcontext: context!)         let request = nsfetchrequest()         //let data = usersettings(entity: entitydescription!, insertintomanagedobjectcontext: context)         request.entity = entitydescription          var dataobjects: [anyobject]?          {             dataobjects = try context?.executefetchrequest(request)         } catch  let error nserror {             print(error)             dataobjects = nil         }          result in dataobjects as! [nsmanagedobject] {             let dataselected = nsarray(array: result.valueforkey("favcategory")! as! nsarray)             print(dataselected)         } 

update: how can receive count of dataselected?

core data isn't capable of storing arrays or dictionaries in first place. remember encountering problem before learning.

aka, dataobjects array doesn't have can typecasted nsarray. way model to-many relationship (which creates set), can imitate array.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -