i know definition single exclamation mark, two?
i coding today , compiler "force" me add 1 more ! sentence:
mysignal.subscribenext({ (value: anyobject!) -> () in let list: racsequence = value["myobject"]!!.rac_sequence ... if use 1 ! mark, project doesn't compile, giving me error: "value of optional type 'anyobject?' not unwrapped; did mean use '!' or '?'?" add 1 more ! , works.
what's meaning two exclamation marks in swift?
you're storing anyobject! in dictionary, you're storing optional value. dictionary subscripts return optional of value you're storing, you're getting optional optional, why need 2 !, unwrap twice.
Comments
Post a Comment