简体   繁体   中英

How do I convert Collection of [UILabel] to string text to display on ViewController?

I am trying to display the same information on a collection of [UILabel] , but I am getting this error,

Value of type ' [UILabel]? ' has no member 'text'

I am getting the specific error on this line in my code.

storagetypelabel.text = "\(booking.storageType.uppercased()) STORAGE"

Would love some input on how to alter the way my property.text label is typed.

Since I hooked up multiple UILabel to one [UILabel] collection, when I call the [UILabel] property, I should be able to display the same information for all the connected labels in the collection right?

text is a property of a single UILabel not an array , To set the text for all labels use

let str = "\(booking.storageType.uppercased()) STORAGE"
storagetypelabel.forEach { $0.text = str }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM