Why are Implicitly Unwrapped Optionals needed if we are sure there is a value?
Hello everyone! I just started learning Swift, and I have one question bothering me. I was reading the documentation and came across something called Implicitly Unwrapped Optionals (IUO). They are declared with an exclamation mark, for example:
```swift
var name: String! = "Alice"
```
I understand that this is an optional that automatically unwraps when accessed, without needing to write `if let` or `guard let`. But what I don't understand is: why is such a type needed at all? If we are sure there is a value (which the exclamation mark hints at), why not just use a regular non-optional type, like `String`? What's the difference?
I've heard that IUOs are often used in UIKit properties, especially in storyboards, for example:
```swift
@IBOutlet weak v
No answers yet.
Log in to leave an answer
Blogs