What is difference between “?” and “!” in Swift?

Use attachment.image!.size if you're guaranteed that image? isn't nil.

If your image is nil then your app will crash. This is called forced unwrapping.

! means it's not allowed to nil and ? means it's allowed to nil.

If you're not sure it won't be nil, use image?.