Welcome to CS193P

iPhone Application Development
Evan Doll
edoll@stanford.edu

Paul Marcos

pmarcos@stanford.edu

Tuesday, September 23, 2008

1

Introductions
• Lecturers
Paul Marcos <pmarcos@stanford.edu> ■ Evan Doll <edoll@stanford.edu>

• Student TAs
Troy Brant <troyb@stanford.edu> ■ Kayvon Beykpour <beykpour@stanford.edu>

• Industry “TAs”
Adam Nash <smashman@stanford.edu> ■ Joe Bernstein <joe@terriblyclever.com>

Tuesday, September 23, 2008

2

Quick Survey
• Have worked with Java or C++? • Have an Intel-based Macintosh? • Have done Mac OS X development? • Have installed the iPhone SDK and done iPhone
development?

Tuesday, September 23, 2008

3

Logistics
• Lectures: Packard 101
Tues & Thurs 12:50 - 2:05 PM • Prerequisite: CS 106B/X • Recommended Book: None, we’ll use Apple documentation • Required Hardware:

You must have access to an Intel-based Macintosh

• Required Software:
Mac OS X 10.5.4 Leopard (or later) ■ iPhone SDK

• iPhone SDK is not currently available on cluster computers

Tuesday, September 23, 2008

4

Office Hours & Web Site
• Office hours

TBD, will be posted on web site and via email cs193p@cs.stanford.edu

• Email

• Web site
http://cs193p.stanford.edu ■ Access restricted to some materials

Tuesday, September 23, 2008

5

Enrollment
• Response has been phenomenal! • Enrollment limited to 50 students • You MUST fill out a survey to be considered
http://tinyurl.com/CS193P ■ Need to be completed by noon tomorrow (8/24)

• Priority will be given as follows:
completed CS106B/X and 108 (or equiv. industry experience) ■ prior C and OOP experience ■ students close to graduating ■ CS majors

• If you don’t get enrolled, you are welcome to audit

You must inform us that you’re auditing

Tuesday, September 23, 2008

6

Why Are We Here?

To build iPhone & iPod touch applications using Cocoa Touch

Tuesday, September 23, 2008

7

Why Are We Here?
• 193P is not just about the iPhone, Cocoa Touch or ObjC • It’s about Software Engineering, as well as object oriented
architecture and design • Exposure to problems and solutions that you might not see in other classes

Tuesday, September 23, 2008

8

Stanford iPhone Pilot
• Applications by Stanford students for Stanford students • Project information:

http://studentapps.stanford.edu/iapps.html http://stanford.terriblyclever.com

• Details on the current applications

• Contact Joe and Kayvon for more details about the program • Keep in mind for final projects

Tuesday, September 23, 2008

9

Cocoa Touch & iPhone SDK
• The Good
Based on Cocoa which is mature, well thought out with highly consistent APIs ■ Provides a very rich starting point for exploring app design ■ Shows “real-world” implementations of OO design patterns ■ Designs learned on iPhone translate directly to Mac OS X

• The Bad
1.0 version of SDK, bound to be some rough edges ■ Exploring new territory with classroom device development

• The Ugly

iPhone developer agreement

Tuesday, September 23, 2008

10

Buzz about the class
• Bloggers asked, “How can they teach the class with Apple’s
NDA?”

“Basically, it's like Fight Club. Once you enroll in the iPhone developer program, you're not allowed to talk about the developer program, the SDK, or pretty much anything until Apple says it's OK.”

Tuesday, September 23, 2008

11

iPhone Developer University Program
• Some materials for the class still covered by confidentiality
clause

Existing iPhone developer program restricts who developers can talk to about SDK details ■ University program allows schools to create teams of students who can talk to each other, exchange applications, etc.

• Students will be “invited” to join our CS193P team

Accepting invitation includes agreeing to honor these terms

• Once accepted, you can download the SDK…and we can talk

Tuesday, September 23, 2008

12

THIS CLASS HAS BEEN RATED

R

STUDENTS STRONGLY CAUTIONED
SOME MATERIAL MAY BE INAPPROPRIATE FOR STUDENTS WHO HAVE NOT ACCEPTED THE UNIVERSITY AGREEMENT

For brief exposure to confidential API and details about iPhone OS. Do not discuss with anyone not enrolled in this class.

Tuesday, September 23, 2008

13

Things We’ll Cover

Tuesday, September 23, 2008

14

Tools Xcode Interface Builder

Frameworks Foundation Language (& Runtime) UIKit

[textView setStringValue: @“Hello”];

Objective-C

Tuesday, September 23, 2008

15

Why Objective-C?
• Exposure to other languages is always good • ObjC is a language focused on simplicity and the elegance of
OO design

Based on ANSI C ■ Brings many object oriented principles, but with a minimal amount of syntax

• A data point to compare with designs of C, C++ and Java

Tuesday, September 23, 2008

16

Applications You Will Build
HelloStanford & Obj-C Tool HelloPoly - 2 weeks Presence - 4 weeks Final Project (your choice) - 3 weeks

Tuesday, September 23, 2008

17

Assignments, Grading & Late Policy
• 7 weekly assignments • Final project of your choice

End of quarter demos at Apple...

• Grading: Nice & simple: ✓, ✓+ and ✓• Late Policy: 3 late days, use them wisely!

Tuesday, September 23, 2008

18

First Assignment
• First assignment handed out today, 2 parts • Intended to get you situated with tools and start off with Obj-C • Includes a comprehensive walkthrough • We suggest trying to do Assignment 1A before Thursday to
help work out any tools or installation issues

Tuesday, September 23, 2008

19

Second Assignment: Presence
• Build a fully functional application from scratch over 4 weeks • Each assignment builds on the previous one

Don’t fall behind!

• Covers a wide variety of topics in the UIKit framework...

Tuesday, September 23, 2008

20

Presence
Bird’s Eye View

Tuesday, September 23, 2008

21

What We’ll Cover
• Application design patterns • View controllers • Presenting data

Table views Property lists, SQLite, web services

• Loading & saving data

• Text input • Performance tuning • Address Book and other system integration • More...? Suggestions welcome!

Tuesday, September 23, 2008

22

Final Projects
• 3 weeks to work on them • Application of your choice • It’s never too early to think of something and propose it to us • Categories to consider:
Student life apps ■ Educational tools ■ Games ■ Social / location-aware software

• Find a project that you or your friends would actually like to
use! • Post it on the app store?

Tuesday, September 23, 2008

23

Questions?

Tuesday, September 23, 2008

24

iPhone OS Overview

Tuesday, September 23, 2008

25

iPhone Mac OS X
Cocoa iPhone OS Media Touch Core Services Core OS

Tuesday, September 23, 2008

26

Core Services Cocoa Media Touch Core iPhone OSOS
Collections Events PNG, TIFF Core Audio Multi-Touch OS X Kernel Core Alerts JPG, Location Power Mgmt Cocoa Touch Address Book OpenAL Multi-Touch Controls Services Mach 3.0 Net Web View PDF Keychain Media Networking Audio Mixing Accelerometer Threading Picker BSD Quartz (2D) Certificates People CoreFile Access Services AudioHierarchy Preferences Picker View Recording CoreSystem Sockets File Image Animation SQLite Video Localization Security Core OS Playback URL utilities OpenGL ES Bonjour Camera

Tuesday, September 23, 2008

27

Tools Xcode Interface Builder

Frameworks Foundation Language (& Runtime) UIKit

[textView setStringValue: @“Hello”];

Objective-C

Tuesday, September 23, 2008

28

Cocoa Touch Architecture
Cocoa Touch UIKit
User interface elements Application runtime Event handling Hardware APIs

Foundation

Utility classes Collection classes Object wrappers for system services Subset of Foundation in Cocoa

Tuesday, September 23, 2008

29

Objects

Tuesday, September 23, 2008

30

Object

Thing

Tuesday, September 23, 2008

31

Behavior

Thing

behavior

doSomething

Tuesday, September 23, 2008

32

Message

Thing
"doSomething"

doSomething

Tuesday, September 23, 2008

33

State

Thing
state flag count

behavior

doSomething

Tuesday, September 23, 2008

34

Other Objects As State
Other Thing Thing
state flag count helper doSomething doSomethingElse performDifficultTask

behavior

Tuesday, September 23, 2008

35

Outlets

Need to decide what the demo would be and update slide to appropriate material. - text field / slider? - color tabs?

Controller
slider label updateLabel

Tuesday, September 23, 2008

36

Target / Action

Controller
slider label updateLabel

target action ʻupdateLabelʼ

Tuesday, September 23, 2008

37

Demo

Tuesday, September 23, 2008

38

Outlets

Controller
slider label updateLabel

Tuesday, September 23, 2008

39

Target / Action

Controller
slider label updateLabel

target action ʻupdateLabelʼ

Tuesday, September 23, 2008

40

Questions?

Tuesday, September 23, 2008

41

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.