The problem is that you need to put your code inside a method. All you need is to move it to viewDidLoad() or any other method.
More Related Contents:
- TableViewCell in Swift?
- How to initialize properties that depend on each other
- Safe (bounds-checked) array lookup in Swift, through optional bindings?
- Error “Thread 1: breakpoint 2.1”
- IBOutlet is nil, but it is connected in storyboard, Swift
- Swift Protocol Extensions overriding
- ‘var’ parameters are deprecated and will be removed in Swift 3
- how to resize a bitmap on iOS
- “Use of undeclared type” in Swift, even though type is internal, and exists in same module
- Creating NSData from NSString in Swift
- Limiting UIDatePicker dates from a particular time. Such as Input DOB to a restricted age limit
- NSTimer not firing when NSMenu is open in Swift
- How can I use swift in Terminal?
- How can I make a countdown with NSTimer?
- What is Communications error: OS_xpc_error in Xcode 6?
- Xcode swift indexing forever
- Redundant conformance error message Swift 2
- Swift – Saving highscore using NSUserDefaults
- trying to animate a constraint in swift
- Print unicode character from variable (swift)
- ‘#selector’ refers to a method that is not exposed to Objective-C
- Class variables not yet supported
- How to present a modal atop the current view in Swift
- Testing if an element is visible with Xcode 7 UITest
- SQLITE_TRANSIENT undefined in Swift
- Swift Playground – Files are not readable
- iAd in xcode 6 with Swift
- Calling Function from another class swift
- How would I repeat an action forever in Swift?
- Animating a constraint in Swift