ios - How to convert [String : String?] to [NSObject : AnyObject]! in Swift 2.0 for Firebase Api? -
how can convert [string : string?] [nsobject : anyobject]!?
right project using firebase backend swift app. after updated xcode 7 , swift 2.0,
i got error .updatechildvalues function , image below.
how can fix this? thanks!
the problem values in dictionary of type string?
, , contain nil
. when dictionary passed objective-c code in firebase, it's converted nsdictionary
. values in nsdictionary
can't nil
.
i'm guessing self.deckname.text
or self.deckdetails.text
returning string?
instead of string
part of sdk update in xcode 7. if you're absolutely never return nil
, can add exclamation point after self.deckname.text
and/or self.deckdetails.text
unwrap string?
string
.
note if make bad assumption , return nil
, program crash. if you're uncertain, self.deckname.text ?? ""
, means "return deckname.text if it's not nil, otherwise return empty string".
Comments
Post a Comment