Skip to content

Instantly share code, notes, and snippets.



Created Jul 16, 2015
What would you like to do?
Bug related to having an optional enum in a struct in Swift
import Foundation
public struct FeaturedItem {
public enum ImageSource {
case Bundled(name: String) // simplified enum with one case to illustrate the bug.
public let localizedTitleImageSource: ImageSource? // This optional causes Swift to barf. If it's non-optional, it compiles fine
// Workaround in this case is to just use an optional String instead of the enum.
extension FeaturedItem {
public static let bundledItems = [ // this needs to have at least one object in the array
localizedTitleImageSource: .Bundled(name: "some name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment