Sorry, meant to come back to this thread days ago...As others have noted, Swift 2 doesn't seem to support what you want it to do. I see a workaround, though... There's still boilerplate code, but it seems less error-prone to meFirst, we need a way to iterate over the enum cases (and provide their default values):class StoryBookStateGenerator : AnyGenerator<StoryBookState> { var optcase:StoryBookState? = nil override func next() -> Generator.Element? { if let cas = optcase { switch cas { case .Welcome: optcase = .Praise(nil, nil) case .Praise: optcase = .InvitationToRepeat(nil, nil) case .InvitationToRepeat: optcase = .TurnToNextPage(nil) case .TurnToNextPage: optcase = .End case .End: optcase = nil } } else { optcase = .Welcome(nil) } return optcase } }Second, we need a way to parse the source code and extract the case labels. For some reason, I couldn't get String(contentsOfFile) to work. Fortunately, someone on stackoverflow was kind enough to post a class that'll read each line of a file into a [S
Topic:
Programming Languages
SubTopic:
Swift
Tags: