Comments on: Hexy Little Thing Official blog of Red Sweater Software Sat, 03 Mar 2007 20:43:43 +0000 hourly 1 By: Bjoern Kriews Sat, 03 Mar 2007 20:43:43 +0000 Hi Daniel, thanks – this is really useful.
I made a minor modification to display the concrete classname
and its address so one can distinguish different objects.

— NSData+RSHexDump.m 2007-02-14 19:47:59.000000000 +0100
+++ NSData+RSHexDump.m.bkr 2007-03-03 21:40:05.000000000 +0100
@@ -53,7 +53,8 @@

// Start the hexdump out with an overview of the content
– NSMutableString *buf = [NSMutableString stringWithFormat:@”NSData %d bytes%@:\n”, [self length], curtailInfo];
+ NSMutableString *buf = [NSMutableString stringWithFormat:@”%@(%p) %d bytes%@:\n”,
+ NSStringFromClass([self class]), self, [self length], curtailInfo];

// One row of 16-bytes at a time …
int i, j;

By: Wevah Thu, 15 Feb 2007 21:53:39 +0000 Nice! (Though I’d probably rather use an NSRange for the second.)

By: Blake C. Thu, 15 Feb 2007 04:19:28 +0000 alexr- I don’t have a mactel, but isn’t the MB plugin PPC-only?

By: Karsten Thu, 15 Feb 2007 03:18:07 +0000 Thanks a lot for this great tip!
I just blogged about something similar. It’s about a project i started some weeks ago about improving the debugging experience in Xcode. You can read it at


By: Daniel Jalkut Wed, 14 Feb 2007 22:32:47 +0000 alexr: Extending that logic would lead one to question the use of – description methods in any classes. I am happy to trade the (quite minimal) code bloat for an improved debugging experience that fits in with the existing object-inspection pattern.

Even with the “dm” command, I’d have to conceptually thing “display memory” and coerce the NSData into an address, instead of using the same “po” habit that I use everywhere.

By: alexr Wed, 14 Feb 2007 22:25:03 +0000 Why bloat your code like this? You should demand more from your debugger.

The MacsBug plugin for gdb has the “dm” command, which can be trivially added via gdb’s scripting language if you don’t want the entire plugin.

By: James Gregurich Wed, 14 Feb 2007 22:10:07 +0000 I did something similar in my work. I wrote a little function that dumps data from a file stream object into a simple buffer and then prints the buffer value to stdout.

I can call this function from the gdb command line then copy and paste the pointer value to the xcode memory browser to view the data.

The ultimate solution to the problem is for apple to beef up the memory browser in xcode and make it more useful and convenient to use. Why shouldn’t you be able to right click on an NSData instance and choose a menu item that brings up a memory browser for it. You should even be able to edit in the memory browser rather than haveing to drop to the gdb command line to manually change items in the buffer.

By: Mark Grimes Wed, 14 Feb 2007 20:10:27 +0000 Thanks for the pointer Daniel, this helps out a lot!

By: scott lewis Wed, 14 Feb 2007 19:27:08 +0000 I think this post provides the answer to the question you posed in the previous one: yes, C is the new assembly. :)