lecture 1
TRANSCRIPT
Stanford CS193pDeveloping Applications for iOS
Fall 2010
StanfordCS193p
Fall 2010
TodayLogisticsLecturesCommunicationHomework / Final ProjectRequirements
iOS Overview
MVCObject-Oriented Design Concept
StanfordCS193p
Fall 2010
LogisticsLecturesTell you (Tuesday)Show you (Thursday)Let you do it yourself (Homework)
Friday TA SectionPractical matters (e.g. debugging)KPCB EntrepreneurshipSpecial topics (guest lecturers)
Communicationhttp://cs193p.stanford.eduLectures, demo code and homeworkClass announcements
Homework7 weekly assignmentsAssigned Thursday after lectureDue the following Wednesday at 11:59pmIndividual work only
Final Project3 weeks to work on itProposal requires instructor approvalSome teams of 2 might be allowedKeynote presentation required (3 mins or so)
StanfordCS193p
Fall 2010
RequirementsMust have a MacIntel-basedSnow Leopard
HardwareNot required for homeworkRequired for final project (iOS4 or iPad) iPod Touch loaners available
TextbookApple on-line documentationhttp://developer.apple.com
PrerequisitesObject-Oriented ProgrammingCS106A&B required, CS107 recommended
Object-Oriented TermsClass (description/template for an object)Instance (manifestation of a class)Message (sent to objects to make them act)Method (code invoked by a Message)Instance Variable (object-specific storage)Inheritance (code-sharing mechanism)Superclass/Subclass (Inheritance relationships)Protocol (non-class-specific method declaration)
You should know these!If you are not very comfortable with all of these, this might not be the class for you
StanfordCS193p
Fall 2010
iOS4 SDKRequired for all homework assignments and final projectIt’s free!Download Xcode/SDK from iOS Dev Center at http://developer.apple.comTo run on a device (not just in simulator), you must join a ProgramiOS Developer University Program = free for Stanford students = Device YES, AppStore NONormal Developer Program = $99/year = Device YES, AppStore YES
iOS Developer University ProgramEnrolled students will receive an invitation to their Stanford e-mail accountsFollow the directions to join the Program and download the Xcode/SDK (if you haven’t already)Submit your UDID to the staff via e-mailValid through the end of the quarter only
StanfordCS193p
Fall 2010
What will I learn in this course?How to build cool appsEasy to build even very complex applicationsResult lives in your pocket!Very easy to distribute your application through the AppStoreVibrant development community
Real-life Object-Oriented ProgrammingThe heart of Cocoa Touch is 100% object-orientedApplication of MVC design modelMany computer science concepts applied in a commercial development platform: Databases, Graphics, Multimedia, Multithreading, Animation, Networking, and much, much more!Numerous students have gone on to sell products on the AppStore
StanfordCS193p
Fall 2010
Core OSOSX Kernel
Mach 3.0
BSD
Sockets
Security
Power Management
Keychain Access
Certificates
File System
Bonjour
iOSCocoa Touch
Media
Core Services
Core OS
StanfordCS193p
Fall 2010
Core ServicesCollections
Address Book
Networking
File Access
SQLite
Core Location
Net Services
Threading
Preferences
URL Utilities
iOSCocoa Touch
Media
Core Services
Core OS
StanfordCS193p
Fall 2010
MediaCore Audio
OpenAL
Audio Mixing
Audio Recording
Video Playback
JPEG, PNG, TIFF
Quartz (2D)
Core Animation
OpenGL ES
iOSCocoa Touch
Media
Core Services
Core OS
StanfordCS193p
Fall 2010
Cocoa TouchMulti-Touch
Core Motion
View Hierarchy
Localization
Controls
Alerts
Web View
Map Kit
Image Picker
Camera
iOSCocoa Touch
Media
Core Services
Core OS
StanfordCS193p
Fall 2010
Platform Components
Tools
Language
Frameworks
Design Strategies
[display setTextColor:[UIColor blackColor]];
Foundation UIKit
MVCCor
e Data
Map Kit
Xcode
Interface Builder
Instruments
Core Motion
StanfordCS193p
Fall 2010
StanfordCS193p
Fall 2010
Controller
MVC
Model View
StanfordCS193p
Fall 2010
Controller
MVC
Model View
Divide objects in your program into 3 “camps.”
StanfordCS193p
Fall 2010
Controller
MVC
Model View
Model = What your application is (but not how it is displayed)
StanfordCS193p
Fall 2010
Controller
MVC
Model View
Controller = How your Model is presented to the user (UI logic)
StanfordCS193p
Fall 2010
Controller
MVC
Model View
View = Your Controller’s minions
StanfordCS193p
Fall 2010
Controller
MVC
Model View
It’s all about managing communication between camps
StanfordCS193p
Fall 2010
Controller
MVC
Model View
Controllers can always talk directly to their Model.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
outlet
Controllers can also talk directly to their View.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
outlet
The Model and View should never speak to each other.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
?outlet
Can the View speak to its Controller?
StanfordCS193p
Fall 2010
Controller
MVC
Model View
outlet
Sort of. Communication is “blind” and structured.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
outlet
target
The Controller can drop a target on itself.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
outlet
target
Then hand out an action to the View.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
outlet
target
The View sends the action when things happen in the UI.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
outlet
should
will did
target
Sometimes the View needs to synchronize with the Controller.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
should
will did
target
The Controller sets itself as the View’s delegate.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
should
will did
target
The delegate is set via a protocol (i.e. it’s “blind” to class).
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
should
will did
target
Views do not own the data they display.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
should
will did
target
countdataat
So, if needed, they have a protocol to acquire it.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
data source
should
will did
target
countdataat
Controllers are almost always that data source (not Model!).
Controllers interpret/format Model information for the View. StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
data source
should
will did
target
countdataat
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
? delegate
outlet
data source
should
will did
target
countdataat
Can the Model talk directly to the Controller?
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
data source
should
will did
target
countdataat
No. The Model is (should be) UI independent.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
delegate
outlet
data source
should
will did
target
countdataat
So what if the Model has information to update or something?
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
Notification& KVO
delegate
outlet
data source
should
will did
target
countdataat
It uses a “radio station”-like broadcast mechanism.
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
Notification& KVO
delegate
outlet
data source
should
will did
target
countdataat
Controllers (or other Model) “tune in” to interesting stuff.
A View might “tune in,” but probably not to a Model’s “station.”StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
Notification& KVO
delegate
outlet
data source
should
will did
target
countdataat
StanfordCS193p
Fall 2010
Controller
MVC
Model View
action
Notification& KVO
delegate
outlet
data source
should
will did
target
countdataat
Now combine MVC groups to make complicated programs ...
MVCs working together
StanfordCS193p
Fall 2010
MVCs not working together
StanfordCS193p
Fall 2010
Coming UpNext LectureOverview of the Development EnvironmentXcodeObjective-C introInterface BuilderConcrete example of MVCMajor demonstration of all of the above: Calculator
Friday (optional)Installing the SDK and using the debugger (this is the only time that will be covered)
Next WeekObjective-C language in depth Foundation classes: arrays, dictionaries, strings, etc.Dynamic and static typingMemory Management Stanford
CS193pFall 2010