ios - Swift: Why all my optional variable looks like "Optional(305.502)" -


this question has answer here:

i've start learning swift. , little confused optional types. have variable var theoptvar: float? can nil make optional ?.
when i'd somewhere @ ui see optional(305.502).
there way have optional var on uilabel without "optional" word?

it displaying “optional” because have changed datatype float optional float.
due whatever value there automatically wrapped optional text.

so if don’t want display optional word extract value out of it.

to add ! mark . this forced unwrapping.

for eg.

var temp : float? temp = 60.5 println(value \(temp!)) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -