DPS923 notes – Tue Jan 27

Register as an Apple Developer. Model classes, again. App and controller initialization. Table views. Classes that describe real-world objects.

.

Quiz 2 is today

Quiz 2 is today. We will do it at the beginning of the timeslot, beginning at 9:50am.

The quiz will be ten (10) minutes in length.

You will answer three questions, on a single sheet of paper. The questions will cover topics, concepts, definitions, descriptions, and so on. Think about a question-and-answer session in a job interview. Those are the kinds of questions you can expect.

.

Register as an Apple Developer

It’s time to do this:

Register as an Apple Developer

.

App initialization

A typical iOS project, when viewed in Finder (the file system), includes at least two items:

  1. an Xcode project file, named <project>.xcodeproject
  2. a folder named <project>

The project file holds settings used by Xcode.

The folder holds your source code, and all the other resources and assets (e.g. images) needed by your project. This is also known as a bundle.

When your app launches, the (Swift) app’s entry point is the ‘app delegate’ class. Notice that its class declaration is preceded by an attribute:
@UIApplicationMain

The Swift Programming Language document in the Language Reference section, describes this feature (search/find “uiapplicationmain”). Also described in this article on the Swift blog.

What is the ‘app delegate’?

Read the introduction to the UIApplcation class in the reference documentation.

Then, read the introduction to the UIApplicationDelegate protocol in the reference documentation.

You can read more about the application object here.

In the app delegate, the most important method to use during app initialization is:
application(didFinishLaunchingWithOptions: )

.

More about model classes

In the previous class/session, you learned the basics of a “model” class, and how to write code for it, so that you could make progress on Lab 2.

The document titled “Model object design for iOS apps” provides more important information that you will need for this week and beyond.

.

Controller initialization

The goal is to enable a controller to initialize – come to life – with all of the data it needs. How is this done?

  1. Ensure that the controller has a property (one or more) to hold the data it needs to initialize
  2. In the event handler that initializes the controller, get the data you need before the controller is initialized
  3. Initialize the controller
  4. Pass the data on to the controller, by simply setting the controller’s property

The first controller that runs is known as the “root view controller”.

From the app delegate, get a reference to this root view controller. Then follow the steps shown above.

Note that this is a best practice, but some of the resources ‘out there’ do not follow this practice. Don’t be swayed – use the best practice. Ask your professor if you have questions.

.

Table view introduction

“A table view presents data in a scrolling single-column list of multiple rows.”
(iOS Human Interface Guidelines)

The UIKit User Interface Catalog has more table view content.

In our apps, we will use table views for these purposes:

  1. Presenting data, enabling hierarchical navigation
  2. Presenting workflow operations, enabling hierarchical processing
  3. Presenting data in a list format, for selection
  4. Any combination of the above

.

Today, we will study the first purpose listed above, “navigation”.

.

.

.

.

.

.

.

.

.

.

.

.

.

Advertisements
  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: