[swift-corelibs-dev] Testcases for NSDateFormatter

Philippe Hausler phausler at apple.com
Sat Feb 27 13:50:58 CST 2016


Just to confirm Will is on point for how it works - the only addendum is that if the internal object is not present it that it does regenerate the CFDateFormatter when that is nil.

In this case the iteration versus map has virtually no difference except for a stylistic choice. 

roughly it would turn out like this:

cfSymbols.bridge().map { ($0 as! NSString).bridge() }

I have some outstanding work to bring in a few more things; I have some initial work for attributed strings but that has not been a priority in comparison to some of the other work we have been doing. I will see if I can get that posted here shortly so others can iterate on it.

> On Feb 27, 2016, at 11:44 AM, Taylor Franklin <taylorleefranklin at gmail.com> wrote:
> 
> Thanks for the response Will, that makes a lot of sense.
> I will be sure to try something along the lines of your code snippet, this weekend.
> 
> I could use a map function for creating the [String], but I'm not sure that is more efficient.
> 
> Thanks again,
> Taylor Franklin
> 
> On Fri, Feb 26, 2016 at 7:28 PM, Will Stanton <willstanton1 at yahoo.com <mailto:willstanton1 at yahoo.com>> wrote:
> Hello Taylor,
> 
> If I understand what you’re asking, I feel like NS(Date/Number)Formatter property getters should be like:
> CFDateFormatterCopyProperty(_cfObject, __CF_PROPERTY__)
> 
> Perhaps Philippe or Tony can confirm? Would like to know what they think.
> (And while I’m at it: Any plans for CFAttributedString and write/read streams to become available?)
> 
> 
> So, ex. for month symbols:
> internal var _monthSymbols: [String]!
> public var monthSymbols: [String]! {
>     get {
>             var symbols = Array<String>()
>             let cfSymbols = CFDateFormatterCopyProperty(_cfObject, kCFDateFormatterMonthSymbols) as! NSArray
>             for obj in cfSymbols {
>                 symbols.append((obj as! NSString)._swiftObject)
>             }
>             return symbols
>     }
>     set {
>         _reset()
>         _monthSymbols = newValue
>     }
> }
> 
> 
> Perhaps there is a more efficient way to make a CFArray into an Array<String>…
> 
> Regards,
> Will Stanton
> 
> > On Feb 26, 2016, at 7:25 PM, Taylor Franklin via swift-corelibs-dev <swift-corelibs-dev at swift.org <mailto:swift-corelibs-dev at swift.org>> wrote:
> >
> > Although, all that is unrelated to my latest question of getting some of the NSDateFormatter properties their proper default values?
> 
> 
> 
> 
> -- 
> Taylor Franklin
> iOS Developer | IBM Mobile Innovation Lab
> 972-207-2051  | taylorleefranklin at gmail.com <mailto:taylorleefranklin at gmail.com>
> Blog: http://taylorfranklin.me <http://taylorfranklin.me/> | LinkedIn: https://www.linkedin.com/in/taylorfranklin <https://www.linkedin.com/in/taylorfranklin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160227/8ceb127d/attachment.html>


More information about the swift-corelibs-dev mailing list