I have the following code.
ViewController.Swift
class ViewController: UIViewController {
override func viewDidLoad() {
let someClass = Test()
someClass.someProtocol.someMethod()
}
}
Code.Swift
protocol SomeProtocol {
var someInt: Int {get set}
func someMethod()
}
class SomeClass: SomeProtocol {
var someInt: Int
init() {
someInt = Int()
}
func someMethod() {
print("hello")
}
}
class Test {
let someProtocol: SomeProtocol
init() {
self.someProtocol = SomeClass()
}
}
This code compiles completely fine on Xcode 6/Swift 1.2, but in Xcode 7/Swift 2
someMethod
is never called, instead I get a EXC_BAD_ACCESS
on someInt
However if I move the code from Code.Swift to the ViewController.Swift file (so that all the source code is in the same file) I don't get a crash.
Has anyone experienced this issue with Swift 2 or know why this is happening? By the way I'm running Xcode 7 beta 2
Thanks