Disons que nous avons cette Enum:référence Ambigu à un membre 'init (de :)' pour Enum
enum NumberEnumSpecial: Int32 {
case two = 2, three = 3
}
Je voudrais qu'il initialiser avec un Int32, donc j'utiliser ceci:
let myEnum = NumberEnumSpecial.init(rawValue: 2)
Cela fonctionne dans un projet de terrain de jeu mais pas dans mon projet App ordinaire. Je reçois cette erreur pour exactement le même code:
Ambiguous reference to member 'init(from:)'
/Users/sjoerd/GitHub/flitsmeister-ios/app/Flitsmeister7/Model/Melding/DangerZone.swift:91:22: error: ambiguous reference to member 'init(from:)'
let myEnum = NumberEnumSpecial.init(rawValue: 2)
^~~~~~~~~~~~~~~~~
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Swift.RawRepresentable:2:24: note: found this candidate
public convenience init(from decoder: Decoder) throws
^
Build failed 13/10/2017, 09:32
En cliquant sur les candidats n'a pas d'effet.
Si vous me demandez il semble y avoir un Enum quelque part dans le code avec une implémentation pour init (from) provoquant cette erreur sur mon Enum. Mais la recherche de ce texte ne me donne aucun résultat.
Quelle est cette erreur et comment trouver ce qui cause cela?
Utilisation de Swift 3.2 et XCode9.0
de solution actuellement:
enum NumberEnumSpecial: Int32 {
case two = 2, three = 3
init?(withSpecialNumber number : Int32) {
self.init(rawValue: number)
}
}
Impossible de reproduire. Pouvez-vous afficher le message d'erreur de compilateur complet à partir du navigateur de rapport? –
Il devrait y avoir un bouton à l'extrémité droite de la ligne "Compile DangerZone.swift" qui montre les messages du compilateur comme * texte. * - Afficher ce texte, pas une capture d'écran. –
Journal complet: https://pastebin.com/18VigRqw –