iOS dev progress checkpoint – topic review/recap

It’s time to stop at a checkpoint. How are you doing so far in this course? This post reviews and summarizes the important topics that you should be learning.

.

iOS development progress checkpoint – topics

During the first few weeks, we will create and work with View-based Applications.

You need to know the purpose of each source code file.

A new view-based app includes two source code file pairs:

  • App delegate – for app startup, and other app runtime events
  • View controller – program logic for a screenful of content

.

A new view-based app includes two nib files:

  • Window nib – the root/base of the view hierarchy
  • View nib – user interface for the screenful of content

.

The view is a property of a view controller (see the UIViewController Class Reference). Stated another way, a view controller manages a view.

When you need to reference a user interface object in the view (e.g. a label, or a text field), you add an outlet to your view controller. Modern apps declare an outlet as a property.

When you need a user interface object to perform an action (e.g. respond to a button tap), you add an action to your view controller. An action is a method.

In Xcode 4, you add outlets and actions in this way:

  1. Arrange your editors so that your user interface (view nib) and view controller interface/header  source code file (.h) are side-by-side
  2. Control + click-drag, from the user interface object (e.g. a button, or label) to your .h source code file, and release the mouse button (and Control key)
  3. Fill out the pop-up box

.

When you create an outlet, Xcode declares a property in your .h interface. It then adds code to the .m implementation (@synthesize and memory management).

When you create an action, Xcode declares a method in your .h interface. Then, you must write code to the .m implementation of the method.

Two important concepts to “get” right away:

  1. The Cocoa runtime is in control, and our main job is to write methods that handle events (user’s touch, and other events in the runtime environment)
  2. The delegation pattern is frequently used

.

Delegation… An object assigns responsibilities to another object. Much like a human assistant.

Some user interface objects have a delegate property (e.g. a UITextField). You set the delegate property to one of your objects (typically your view controller). In addition, the view controller must adopt (conform to) a formal protocol.

For example, a UITextField has a delegate property:

  1. Set it to your view controller object
  2. Add this protocol declaration to the view controller .h:

    <UITextFieldDelegate>

  3. Implement the protocol’s required methods, and any desired optional methods, in the view controller .m implementation

.

Handling the keyboard is done with delegation. It’s a good way to learn the concept.

.

A class is a container for Objective-C source code:

  • Instance variables (ivars) – state that has no public accessors
  • Properties – state that can be accessed publicly
  • Methods – your own, and those inherited from the superclass hierarchy

.

A class can adopt (aka conform to) a formal protocol. See the app delegate for an example. You must implement the protocol’s required methods, and can implement its optional methods.

Know the following about methods:

  • The method’s declaration convention and syntax
  • The method’s calling/use convention and syntax

.

Data types in Objective-C:

  • Includes C scalars and structs
  • Includes Cocoa types, like NSString and NSNumber
  • Must use pointer reference asterisk for pointer types

.

Get comfortable with strings and numbers, and conversions between them.

.

App launch/startup – where do you place the initialization code? It depends; we’ll learn this, and see this in the “Events” series of example apps.

.


.

.

.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: