How can I run a command line command like hexdump from within my iOS app?
On MacOS X, you could do this using NSTask
to run whatever program you want. You'd use NSPipe
to send data to and/or get data from the command.
But you can't do that on iOS. First of all, the hexdump
command may or may not exist in a standard iOS installation. Second, NSTask
isn't available. If you really just want to dump the bytes from a file into a label, it's not difficult. I'd look at using NSInputStream
to open the file and read its data, and then convert each byte to an appropriate hex string and add that to a larger string that'll accumulate the total dump. Once you're done, assign that larger string as the text of the label. Or, you could do the same thing yourself by just reading the file into an instance of NSData
and iterate over the bytes
yourself to produce the hex string.