You need to use conditional binding to avoid it.
For example:
var name : String?
name = "Hello world"
if let unwrappedName = name as? String
{
// Now unwrappedName isn't optional
}
Basically, unwrappedName will be String AKA not optional.
But it really all depends what you are trying to achieve, if you know for sure that name
will never be nil I'd suggest using implicitly unwrapped:
var name : String!
But using implicitly unwrapped suggest that name could be nil thus the conditional binding need to be checked again - it all depends on how sure are you that the variable will never be nil.