The first four lines in your code are outside any context. You can't do that. No executable code can appear except inside a function — usually, some method of some class.
So those four lines need to be inside the ViewController class, not before it, and again, not just loose inside it, but in some method of the ViewController class.
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.