I think you have the code in the wrong place in the class same like this question.
so move it to any function or in viewDidLoad
method.
Hope it will help.
More Related Contents:
- How to move to another page directly without click a button in Swift
- Delete the story board and this error show in all project
- Swift saving and retrieving custom object from UserDefaults
- AnyObject not working in Xcode8 beta6?
- How to create radio buttons and checkbox in swift (iOS)?
- How to increase the height of navigation bar in Xcode?
- Xcode 7.3: import Module displayed with strikethrough
- Connect Objective-C framework to Swift iOS 8 app (Parse framework)
- Swift 2: Call can throw, but it is not marked with ‘try’ and the error is not handled
- Xcode beta 6 iOS 8: Simulator not working
- Swift default AlertViewController breaking constraints
- How to debug an iOS extension (.appex)?
- Xcode 6 isn’t autocompleting in Swift
- How to keep a round imageView round using auto layout?
- The supportedInterfaceOrientations method doesn’t override any method from its superclass
- Changing text of UIButton programmatically swift
- How to change UIButton image in Swift
- Swift ios check if remote push notifications are enabled in ios9 and ios10
- After switching to Xcode 7, app size grew from 9 MB to 60 MB, is there a fix?
- Swift performSegueWithIdentifier not working
- Xcode Version 6.1 (6A1030) – Apple Mach O-Linker Error – Building
- How do you create a UIImage View Programmatically – Swift
- How can I combine two Dictionary instances in Swift?
- Check if location services are enabled
- import swift class in objective-c, -Swift.h file not found
- Disable zoom in WKWebView?
- How to pass data from child to parent view controller? in swift
- How to use UnsafeMutablePointer in Swift 3?
- Swift compatibility between versions for a library
- Black screen after adding SceneDelegate and updating Info.plist