Created
July 16, 2015 14:03
-
-
Save jbrennan/5dbbc52c9670c2846c2c to your computer and use it in GitHub Desktop.
Bug related to having an optional enum in a struct in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
FeaturedItem( | |
localizedTitleImageSource: .Bundled(name: "some name") | |
) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment