Capturing Screenshots

Since you have to submit screenshots as part of your Mock App Store Submission, I thought I’d take a moment to detail some techniques for doing so.

iPhone Simulator

If you’re on the iPhone Simulator, the easiest way to take a screenshot of just the screen is to hold down Control and select “Copy Screen” from the “Edit” menu. This can also be accessed by pressing Control-Command-C.

Copy Screen

Copy Screen

Then, the easiest way to create an image from the clipboard is to open the Preview app (can launch via spotlight) and select “New from Clipboard”.

New from Clipboard

New from Clipboard

Then you can simply save the image as a PNG.

iPhone Device

There are 2 easy ways to get screen captures from an iPhone OS device — through Xcode or using the iPhone’s built in screen capture utility. I prefer using Xcode as it takes a lossless PNG images, whereas the device seems to capture lossy JPG images.

To capture using Xcode, plug in your device and bring up the Organizer by selecting “Organizer” from the “Window” menu.

Opening the Organizer

Opening the Organizer

Once open, select your iPhone OS device and then select the “Screenhots” tab. To capture a screenshot, simply press the “Capture” button and the most recent screenshot taken will be displayed in the right panel and all screenshots will appear in the left panel. Though not obvious, you can easily save any image on the left by simply dragging it out of Xcode’s Organizer into a Finder window.

Screen Capture using Organizer

Screen Capture using Organizer

To capture using the iPhone’s built in screen capture utility simply hold the home button and press the sleep/wake button. You should see an on-screen flash when a capture is taken. The screenshot will then appear in an album in your Photos app, which you can then email or sync off of the device.

Functionize User Script

Here’s another user script I wrote to save time typing that didn’t make the Advanced Xcode lecture notes…

#!/usr/bin/env ruby

STDIN.read.each do |line|
    puts line.rstrip.gsub(/\s*;/, " {\n\n}\n\n")
end

This script is intended to be used after copying method declarations from a header file into an implementation file. Once your method declarations are pasted into the .m file, simply select them and run the script. It will turn the declarations from this…

- (void)foo;
- (int)bar:(int)i;
- (IBAction)doSomething:(id)sender;
- (id)someReallyLongWindedMethod:(int)x
               thatSpansMultiple:(NSString *)y
                linesInTheHeader:(NSDictionary *)z;

…into stubbed out method implementations, like this…

- (void)foo {

}

- (int)bar:(int)i {

}

- (IBAction)doSomething:(id)sender {

}

- (id)someReallyLongWindedMethod:(int)x
               thatSpansMultiple:(NSString *)y
                linesInTheHeader:(NSDictionary *)z {

}

Xcode Cheatsheet

Given that many of your are just starting to learn Xcode, I thought I’d take a moment to share Mike Clark‘s great free Xcode shortcuts cheatsheet. This cheatsheet covers many “essentials” that I use regularly and may be worthwhile to bookmark or print out while you’re getting up to speed with Xcode.

Xcode Shortcuts

Xcode Shortcuts

Mike also sells a couple of Xcode screencasts through The Pragmatic Bookshelf if interested.