Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Swift base class exceptions
* Code to my question
* I don't understand why there's such a difference in these two Formatters behavior
import Cocoa
class OverridenFormatter: NSNumberFormatter {
override func getObjectValue(obj: AutoreleasingUnsafeMutablePointer<AnyObject?>, forString string: String, range rangep: UnsafeMutablePointer<NSRange>) throws {
// not doing anything, just delegating to the base class
try super.getObjectValue(obj, forString: string, range: rangep)
class NonOverridenFormatter: NSNumberFormatter {}
let nonOverridenformatter = NonOverridenFormatter()
let overridenFormatter = OverridenFormatter()
nonOverridenformatter.minimum = 15
overridenFormatter.minimum = 15
// WHY these calls yield different results ?
nonOverridenformatter.numberFromString("14") // return nil
overridenFormatter.numberFromString("14") // throws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.