[swift-users] Date and Data

Travis Griggs travisgriggs at gmail.com
Wed Aug 3 17:33:42 CDT 2016


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.


More information about the swift-users mailing list