ios - cast from [String:AnyObject] to unrelated type NSMutableDictionary always fails Warning -


code working, how silent warning keeps on appearing every time?

let parentview = self.parentviewcontroller as! sbprofileviewcontroller parentview.saveddetailsmodel = sbsavedusermodel(data:responseobject["data"].dictionaryobject! as! nsmutabledictionary) 

cast '[string:anyobject]' unrelated type 'nsmutabledictionary' fails warning

savedusermodel stores saved information:--

class sbsavedusermodel : nsobject {  var userid : string! var firstname : string! var lastname : string! var imagebase64 : string!  required init ( data : nsmutabledictionary) {     self.userid =  data.objectforkey("userid") as! string     self.firstname = data.objectforkey("fname") as! string     self.lastname = data.objectforkey("lname") as! string     self.imagebase64 = data.objectforkey("image") as! string } 

try replacing

responseobject["data"].dictionaryobject! as! nsmutabledictionary

with this:

nsmutabledictionary(dictionary: responseobject["data"].dictionaryobject!)

you cast nsdictionary, reason when want nsmutabledictionary, have initialize new 1 nsmutabledictionary(dictionary:)

edit: see comment on question @tommy why necessary.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -