I read an interesting dev tip by Erica Sadun at TUAW. It was about creating button images with the help of an undocumented class left in the simulator. Neat. Why not try to make a slightly more convenient app to create buttons?
Said and done. It wasn’t to hard to whip together a small app that easily saved two images to the
/tmp directory. But, now to the reason for this blog entry. I really wanted those images to be opened in
Preview to be viewed and saved in another location if I wanted to. First I was hoping that some parts of the Mac OS was still available to be used for ie calling
system(..) with a command to open the image files in
Preview. Well, I couldn’t find anything working to reach out of the simulator. So, how could I make this work?
I remembered that the output of
NSLog(..) are also outputted in the system log. Why not make a simple monitor script that trigger on a special output? Not a nice solution, but it works. The monitor script was really easy to create using
tail -f and
Want to see how I did it all? Grab the Xcode project at github
The monitor script is called
LOG_MONITOR and can be started from within Xcode, just ctrl-click it and select Open With Finder and it should open a
Terminal window. Now run the
CreateButton app in the simulator and press
Preview. This should bring up the two images, one for the normal button and one for the pressed button.