iOS swift variable value came as optional

Solution:

In swift it has two type of objects one is unwrapped and another one is wrapped.

Unwrapped:

let name = nameValue as? Int

Wrapped:

let name = nameValue as! Int

If you tried with unwrapped then it will came as optional value.So if you can use as wrapped format it will came with original value.

One more thing that if you assigned other datatype value then unwrapped function will not force close your app.Because it will skip the data if not matches the data type.

In wrapped format it will force closes your app when you assigned the other datatype values.

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift