No hex dump anymore in Data description

Is it intentional that the description method of Data returns only the number of bytes, but not a hex dump of the contents (as NSData did)?

    let data = Data(bytes: [1, 2, 3])
    print(data) // 3 bytes
    print(data.debugDescription) // 3 bytes

Of course I can bridge back to NSData:
    
    print(data as NSData) // <010203>

But other collection types (Array, Dictionary, Set) print all their elements, regardless of the size of the collection.

For debugging purposes, the "old behavior" of returning a hex dump would be useful.

Martin

It doesn’t really matter if it was intentional or not; if it’s annoying then you should file a bug about it anyway. [I’d file my own but it’d go into Radar and you wouldn’t be able to see it )-: ]

Share and Enjoy

···

On 27 Aug 2016, at 07:45, Martin R via swift-users <swift-users@swift.org> wrote:

Is it intentional that the description method of Data returns only the number of bytes, but not a hex dump of the contents (as NSData did)?

--
Quinn "The Eskimo!" <http://www.apple.com/developer/&gt;
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

Done: [SR-2514] Add a "hex dump" method to `Data` · Issue #4115 · apple/swift-corelibs-foundation · GitHub .

Martin

···

Am 29.08.2016 um 10:51 schrieb Quinn The Eskimo! via swift-users swift-users@swift.org:

On 27 Aug 2016, at 07:45, Martin R via swift-users swift-users@swift.org wrote:

Is it intentional that the description method of Data returns only the number of bytes, but not a hex dump of the contents (as NSData did)?

It doesn’t really matter if it was intentional or not; if it’s annoying then you should file a bug about it anyway. [I’d file my own but it’d go into Radar and you wouldn’t be able to see it )-: ]

Share and Enjoy

Quinn "The Eskimo!" http://www.apple.com/developer/
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

1 Like