Why does the compiler tell me I need to unwrap a Bool (non-optional?)

Viewed 2001

According the the Swift header for String

the property isEmpty is a Bool (not an optional right?)

public var isEmpty: Bool { get }

but in my code, when I try to write:

!sender.titleOfSelectedItem?.isEmpty

Value of optional type Bool? not unwrapped, did you mean to use "?" or "!"

Why does the compiler think that isEmpty is an optional?

Is it because the object that contains the property is currently an optional?

titleOfSelectedItem is a String?

or am I just missing something entirely, here?

1 Answers
Related