Swift: why is label.text optional but textView.text is an expanded string?

I tried the following code in a playground

import UIKit

let label = UILabel()
let textView = UITextView()

let labelText = label.text           // nil
let textViewText = textView.text     // ""

      

If I press Option lableText

, type String?

.
If I press Option textViewText

, type String!

.

Why is the label text optional if the TextView text is not?

+3


source to share





All Articles