Swift 'text' is unavailable: APIs deprecat

2019-03-05 20:46发布

I keep having this error

I've seen other questions been answered by using textLabel.text, but it doesn't work in my case

enter image description here

I'm new to swift so could someone please explain me why and how to solve this.

标签: swift xcode6
1条回答
劳资没心,怎么记你
2楼-- · 2019-03-05 21:12

You need to unwrap textLabel by using an ! after textLabel.

This is because textLabel is an Optional (hence the textLabel? type instead of just textLabel). Read more about optionals here.

Hope that helps!

查看更多
登录 后发表回答