[swift-users] Date and Data

Jon Shier jon at jonshier.com
Wed Aug 3 17:36:13 CDT 2016


If you think Date and Data look similar at a glance, wouldn’t NSDate and NSData? Or are you comparing this against your old Array<UInt8> type?

> On Aug 3, 2016, at 6:33 PM, Travis Griggs via swift-users <swift-users at swift.org> wrote:
> 
> I realize this ship has probably sailed a long while ago. I really like the way the Foundation library is shaping up. With the changes in Swift3, I’ve been moving any of my Array<Uint8> cases to using Data. A handful of handy extensions to Data have made working with it nice. It’s much easier to figure out how to extend Data than Array<UInt8>. And of course, the UIKit/Cocoa libraries love Data things.
> 
> That said, one minor nit I’ve noticed, especially with the inclusion of Date and the dropping of the NS prefixes, is that when I’m scanning code, Date and Data look a lot a like. Where Swift tries so hard to be expressive, this ends up being a dissapointment. My particular app uses quite a bit of both.
> 
> Of late, I’ve added a
> 
> typealias Bytes = Data
> 
> and begun replacing Data references with Bytes.
> 
> It’s too early to tell if its a good replacement or not. I recognize this is a minor issue, rooted in the history of NSData and who knows what else. But I thought I’d shared the feedback anyway.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list