extension Color {
public enum ColorUsage {
case home([String])
case school([String])
case park([String])
var description: String {
switch self {
case .home: return "my home"
case .school: return "kid school"
case .park: return "family park"
}
}
func getValue() -> [String] {
switch self {
case .home(let value),
.school(let value),
.park(let value):
return value
}
}
}
func findColor(places: [ColorUsage]) {
for eachPlace in places {
...
}
}
}
class MyClass {
func useColor() {
let places = [.home(["home1", "home2"]), .school(["AAA", "BBB"]), .park(["you park", "his park"])] /// issue with 'Cannot find type '.home' in scope'
let places = Color.findColor(places: places)
let places = Color.findColor(places: [.home(["home1", "home2"]), .school(["AAA", "BBB"]), .park(["you park", "his park"])]) /// no issue
}
}
0 comments:
Post a Comment
Thanks