Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Cheat Sheet

iPad Application Development For Dummies

The UIKit framework provides a great deal of your iPad application’s basic functionality. As you develop your iPad app, you customize the behavior of the UIKit framework by using subclassing and target-action, but one challenge facing new developers is determining which of these mechanisms to use when. (Keeping track of what view controller method to use when can also be a bit tricky.) These tips can help you decide.

When to Use Subclassing in iPad App Development

Subclassing is one of the mechanisms you use to customize behaviors while you're developing your iPad application. Subclassing involves two stages: (1) creating a new class, called a subclass, that inherits properties from another (super) class and then (2) adding properties as needed for your iPad application. In general, you’ll want to subclass

  • UIView, to create your (more complex) content views, which you may fill with controls, graphics, or the like.

  • UIViewController, to manage the content views and connect it to the model.

  • NSObject, to create Model views and delegates.

Knowing the Target-Action Patterns for iPad App Development

Following are the Target-Action patterns that you use when programming iPad applications. You generally will specify the target as the view controller (which you’ll have already subclassed) because it controls the view in which these controls reside.

  • UITabBarItem (for items on the tab bar)

  • UIBarButtonItem (for items on the navigation bar and tool bar)

  • UIButton

  • UIDatePicker

  • UIPageControl

  • UISegmentedControl

  • UITextField

  • UISlider

  • UISwitch

View Controller Methods: Doing What When

Developers struggle with knowing what view controller methods to use, and when. Picking the wrong method to refresh your user interface can result in an app that disappoints the users.

To understand when to do something in the UIKit framework, you need to know when messages are sent, especially to view controllers.

View controllers have a life cycle just as applications do, and certain messages are sent as views that are displayed and hidden.

The two methods you need to know about in order to work with views are the following:

  • viewDidLoad

  • viewWillAppear:

The following table summarizes what you should do in which method:

Method When to Send It What to Use It For
viewDidLoad After the view controller has loaded its associated views into memory Perform additional view initialization on views loaded from the storyboard or nib file. For example, if you are displaying some static text, load that text here.
viewWillAppear: When the view is about to become visible Do the things that are necessary to present the view. For example, if you are displaying the location of the nearest book store that carries iPad Application Development For Dummies, update that information in this method.

The viewDidLoad message is sent to the view controller after the view controller has loaded its associated views into memory. This method is used to perform view initialization and is not necessarily called every time the view appears. If, for example, the user makes a selection in the view that causes a new view controller to load and slide its view into place, and the user then taps the Back button, this message is not sent when the originating view reappears. That is the job of viewWillAppear:.

The viewWillAppear: message is sent when the view is about to become visible. The first time it is sent is after the viewDidLoad message and then whenever the view reappears, such as when you tap the Back button, for example. You use this method to refresh your user interface, if needed, but not for initialization.

Using Objective-C Operators in iPad App Development

Objective-C operators, like those in other programming languages, let you perform operations on variables (hence the name). Objective-C provides many operators, and keeping track of all of them can be difficult as you program your iPad app. Use the following tables to jog your memory as to which operator accomplishes what task.

Arithmetic Operators
Operator What It Does
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
Relational and Equality Operators
Operator What It Does
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Logical Operators
Operator What It Does
! NOT
&& Logical AND
|| Logical OR
Compound Assignment Operators
Operator What It Does
+= Addition
-= Subtraction
*= Multiplication
\/= Division
\%= Modulo
&= Bitwise AND
|= Bitwise Inclusive OR
^= Exclusive OR
<<= Shift Left
>>= Shift Right
Increment and Decrement Operators
Operator What It Does
++ Addition
-- Subtraction
*= Multiplication
/= Division
%= Modulo
&= Bitwise AND
|= Bitwise Inclusive OR
^= Exclusive OR
<<= Shift Left
>>= Shift Right
Bitwise Operators
Operator What It Does
& Bitwise AND
| Bitwise Inclusive OR
^ Exclusive OR
~ Unary complement (bit inversion)
<< Shift Left
>> Shift Right
Other operators
Operator What It Does
() Cast
, Comma
Sizeof() Size of
? : Conditional
& Address
* Indirection
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!