O'Reilly logo

Learning iPhone Programming by Alasdair Allan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending Email

The MFMailComposeViewController class provides access to the same interface used by the Mail client to edit and send an email. The most common way to present this interface is to do so modally using the presentModalViewController:animated: method, just as we did in the preceding section to create a reusable web view class.

We can therefore reuse our Prototype application code from the preceding section to demonstrate how the mail composer works; we’ll just drop in a class that displays the mail interface instead of the web interface. Open the Finder and navigate to the location where you saved the Prototype project. Right-click on the folder containing the project files and select Duplicate; a folder called Prototype copy will be created containing a duplicate of our project. Rename the folder Prototype2, and then open the new (duplicate) project inside Xcode and use the ProjectRename tool to rename the project itself.

Next, prune back the code:

  1. Open the copy of the project in Xcode and delete the WebViewController.h, WebViewController.m, and WebView.xib files by right-clicking on each file in the Groups & Files pane and selecting Delete from the pop-up menu. When prompted, click Also Move to Trash. If you moved WebView.xib into your Resources folder with the rest of the NIBs, look for it there.

  2. Now click on the PrototypeViewController.m file to open it in the editor. Delete the line where you import the WebViewController.h file and delete all the code in the pushedGo: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required