iPhone 101
Code Tips
Resources
Links
Subscribe
More
This tutorial was written for Xcode 3.2; it's outdated now. For a more up-to-date tutorial, check out Apple's App Development Tutorial to learn how to write iOS apps. There are also lots of other excellent books and online tutorials you can learn from.
I'll still be posting code tips and shortcuts to idev101; click here for the index. If you'd like to get updates, follow me on Twitter, or by RSS or E-mail.
At this point your project should be ready to build and run. Click on "Build" and check the build results window for warnings or errors.
Build Warnings?
It's best to never ignore warnings in the build results. In most cases you can assume a warning is an error, and will result in a crash.
Warnings appear with a yellow warning triangle icon in both the build results and in your code. If the warning message scrolls off the edge of the results window, click on the "more" link to see the complete warning message.
The above warning is what you'll see if you forget to #import "FlowerViewController.h" at the top of MyViewController.m. When you click on a warning or error in the Build Results window, you'll see the error highlighted in your code in the bottom frame. You'll also see the errors when you view the code in the regular Xcode editor.
Author's note: I'd like to put together a list of common warnings and errors that might be encountered in this project. If you've got a warning, error, or crash, please email me the info on it. I'll try to help you solve it!
Run it!
Once the project builds successfully, select "Build and Run" to run it in the simulator. Test it to be sure that the FlowerImageView appears when you press the "Show Image" button, and disappears when you press the "X" button.
If your app crashes, look at the debugger window. The cause for the crash is in there somewhere, though you may have to scroll back a ways to find it.
Source Code
Second.zip
Advanced Controllers
This project has given you practice at adding images and properties, and adding subviews to a view. For a real app, however, you're probably going to want to use a more advanced controller to manage your views. Two of the most common ones are the Navigation Controller and the Tab Bar Controller.
In the next project we'll use a Navigation Controller to handle switching views.
