-
-
Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I write on a variety of technology and software development topics. I've also recently returned from a 3.5-year journey around Europe in a motorhome.
I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and The Amazing Audio Engine, the iOS audio framework.
Getting Data out of the iPhone while Debugging
Here’s a utility I whipped up quickly to save out a file from a hex string, as from
[NSData description]
— kinda a reverse hexdump.While doing some debugging, I realised I needed to visualise an intermediate UIImage from the iPhone’s camera. Not being able to use the simulator, and thus be able to write to a file easily, this was my solution:
po UIImageJPEGRepresentation(photo, 0.8)
to print out the data as a hex string, then copied it to the clipboard, saved it as a text file, and used an NSScanner to scan in each int, fix the endianness and write it out as a file.Insane? Maybe, but it did the trick. So, I turned it into a service that takes the selected hex string and writes it to the Desktop.
This is the service: SaveHexStringAsData.service.zip (unzip it to
Library/Services
)In the debugger, print an NSData, then select the hex string (not including the surrounding angle brackets), then select this service. The data will be saved to your Desktop – rename it to the appropriate file type to open it.
Here’s the source: