Created
March 3, 2016 09:33
-
-
Save below/41d8425f1274e4a05245 to your computer and use it in GitHub Desktop.
Why is the NEHotspotHelperConfidence not nil if out of bounds?
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 UIKit | |
import NetworkExtension | |
//: First a classical enum. As documented, it will be nil if initialized with a rawValue outside of bounds | |
//: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html | |
enum Foobar : Int { | |
case foo | |
case bar | |
} | |
if let faz = Foobar(rawValue: 4) { | |
print ("Valid foobar") | |
} | |
else { | |
print ("No foobar") | |
} | |
//: Now the NEHotspotHelperConfidence, defined as: | |
/* | |
public enum NEHotspotHelperConfidence : Int { | |
case None | |
case Low | |
case High | |
} | |
*/ | |
if let confidence = NEHotspotHelperConfidence(rawValue: 120) { | |
switch (confidence) { | |
case .None : | |
print ("None") | |
case .Low: | |
print ("Low") | |
case .High: | |
print ("High") | |
} | |
} | |
else { | |
print ("Unknown") | |
} | |
// My expected result would be "Unknown", but it is "None". What is going on here? Is this a bug? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment