I have an enum called Foo in type of String.
I have a struct called MyStruct, which has an optional Foo instance that I want it to be nil initially.
Also MyStruct has a failable initializer.
Problem: When I make MyStruct have both failable initializer and optional Foo instance which will be nil initially, my build fails and I get "Segmentation fault: 11."
There is no problem when I rename MyStruct as MyClass and change its type as class.
Is there anyone can tell me why I cannot use both failable initializer and optional enum initialized as nil in a struct?
import Foundation enum Foo: String { case Bla = "blabla" } public struct MyStruct { var myEnum: Foo? public init?() {} } var myStruct = MyStruct() if let myEnum = myStruct?.myEnum { println("myEnum is not nil => \(myEnum.rawValue)") } else { println("myEnum is nil") }