How to resolve "'nil' used before being initialized" in swift?

Example:

var name: String?
print(name!)
This error suggests that you are forcefully unwrapping an optional that hasn't been initialized.

Solution:

var name: String? = "John"
print(name!)

Beginner's Guide to Swift