[swift-corelibs-dev] local copy of formatter properties
Will Stanton
willstanton1 at yahoo.com
Mon Jan 18 23:30:17 CST 2016
Greetings,
I was wondering if there is a reason for keeping local copies of formatter attributes in NSDateFormatter and NSNumberFormatter. Why not create the CF formatter on initialization and pass attributes live?
For instance, instead of this (from line 509 of NSNumberFormatter.swift):
internal var _minusSign: String!
public var minusSign: String! {
get {
return _minusSign
}
set {
_reset()
_minusSign = newValue
}
}
this:
public var minusSign: String! {
get {
return CFNumberFormatterCopyProperty(_cfFormatter, kCFNumberFormatterMinusSign) as! String
}
set {
return CFNumberFormatterSetProperty(_cfFormatter, kCFNumberFormatterMinusSign, newValue as! AnyObject)
}
}
I feel like the existing code is a bit messy with the _reset() and _setFormatterAttribute() action, with the reset’s affecting performance if a property changed between string creation.
Regards,
Will Stanton
More information about the swift-corelibs-dev
mailing list