i O S M o b i l e

advertisement
iOS Mobile
Development
Today
What is th is class all about?
Descr ipt ion
Prerequisites
iOS Over view
What ’s in iOS?
MVC
Object- O r iented Design Concept
Object ive C
(Time Per mitt ing)
New language!
Basic concepts only for today.
What will I lear n in th is course?
How to build cool apps
Easy to build even ver y complex applicat ions
Result lives in your pocket or backpack!
Ver y easy to distr ibute your applicat ion through the AppStore
Vibrant development community
Real - life Object- O r iented Programming
The heart of Cocoa Touch is 100% object-or iented
Applicat ion of MVC design model
Many computer science concepts applied in a commercial development plat for m:
Databases, Graphics, Mult imedia, Mult ithreading, Animat ion, Networking, and much, much more!
Numerous stu dents have gone on to sell products on the AppStore
Prerequisites
Most Important Prereq!
You should know these ter ms!
Object- O r iented Programming
I f you are not ver y comfortable with all of these,
this might not be the class for you!
Object- O r iented
Ter ms
Class (descript ion/template for an object)
Instance (manifestat ion of a class)
Message (sent to object to make it act)
Method (code invoked by a Message)
Instance Var iable (object-specific storage)
Superclass/Subclass (Inher itance)
Programming Exper ience
This is an upper - level CS course.
I f you have never written a program where you
had to design and implement more than a handful
of classes, this will be a big step up in difficult y
for you.
Assignments
Weekly Homework
Final Proje ct
6 weekly (approx imately) assignments
In dividual work only
Required Tasks and Evaluat ion criter ia
You choose the topic
Teams (Optional)
Keynote presentat ion required (5-10 minutes)
What ’s in iOS?
Core OS
O S X Ker nel
Mach 3.0
BSD
Socket s
Secur it y
Power Management
Keychain Access
Cert ificates
File System
Bonjour
What ’s in iOS?
Core Se r vices
Collect ions
Core Locat ion
Address Book Net S er vices
Net working
Threading
File Access
Preferences
SQL ite
URL Ut ilit ies
What ’s in iOS?
Media
Core Audio
OpenAL
Audio Mix ing
Audio Recording
Video Playback
J P E G, PNG, T I F F
PDF
Quart z (2D)
Core Animat ion
OpenGL ES
What ’s in iOS?
Cocoa Touch
Mult i-Touch
Core Mot ion
View Hierarchy
Localiz at ion
Cont rols
Alert s
Web View
Map Kit
Image Picker
Camera
Plat for m Components
Tools
X code 5
Language
[display setTextColor:[UIColor blackColor]];
Frameworks
Foundat ion
Design S trategies
MVC
UIKit
MVC
Cont roller
Model
View
Divide objects in your program into 3 “camps.”
MVC
Cont roller
Model
View
Model = What your applicat ion is (but not how it is displayed)
MVC
Cont roller
Model
View
Cont roller = How your Model is presented to the user (U I logic)
MVC
Cont roller
Model
View = Your Cont roller ’s minions
View
MVC
Cont roller
Model
View
I t ’s all about managing communicat ion between camps
MVC
Cont roller
Model
View
Cont rollers can always talk direct ly to their Model.
MVC
Cont roller
out let
Model
View
Cont rollers can also talk direct ly to their View.
MVC
Cont roller
out let
Model
View
The Model and View should never speak to each other.
MVC
Cont roller
out let
Model
?
View
Can the View speak to its Cont roller ?
MVC
Cont roller
out let
Model
View
Sort of. Communicat ion is “blind” and str uctured.
MVC
target
Cont roller
out let
Model
View
The Cont roller can drop a target on itself.
MVC
target
act ion
Cont roller
out let
Model
View
Then hand out an act ion to the View.
MVC
target
Cont roller
out let
act ion
Model
View
The View sends the act ion when th ings happen in the UI .
MVC
target
Cont roller
out let
act ion
should
will
Model
did
View
Somet imes the View needs to synchronize with the Cont roller.
MVC
should
will
target
did
Cont roller
out let
act ion
Model
View
The Cont roller sets itself as the View’s delegate.
MVC
should
will
target
did
Cont roller
out let
act ion
Model
View
The delegate is set via a protocol (i.e. it ’s “blind” to class).
MVC
should
will
target
did
Cont roller
out let
act ion
Model
View
Views do not own the data they display.
MVC
should
will
target
did
Cont roller
out let
act ion
Model
data
at
View
count
S o, if needed, they have a protocol to acquire it.
MVC
should
will
target
did
Cont roller
data
at
count
out let
act ion
Model
View
Cont rollers are almost always that data source (not Model!).
MVC
should
will
target
did
Cont roller
data
at
count
out let
act ion
Model
View
Cont rollers inter pret/for mat Model infor mat ion for the View.
MVC
should
will
target
did
Cont roller
?
data
at
count
out let
act ion
Model
View
Can the Model talk direct ly to the Cont roller ?
MVC
should
will
target
did
Cont roller
data
at
count
out let
act ion
Model
View
No. The Model is (should be) U I independent.
MVC
should
will
target
did
Cont roller
data
at
count
out let
act ion
Model
View
So what if the Model has infor mat ion to update or something?
MVC
should
will
target
did
Cont roller
data
at
Not ificat ion
& KVO
Model
count
out let
act ion
View
I t uses a “radio stat ion” - like broadcast mechanism.
MVC
should
will
target
did
Cont roller
data
at
Not ificat ion
& KVO
Model
count
out let
act ion
View
Cont rollers (or ot her Model) “tune in” to interest ing st uff.
MVC
should
will
target
did
Cont roller
data
at
Not ificat ion
& KVO
Model
count
out let
act ion
View
A View might “tune in,” but probably not to a Model’s “stat ion.”
MVC
should
will
target
did
Cont roller
data
at
Not ificat ion
& KVO
Model
count
out let
act ion
View
Now combine MVC groups to make complicated programs . .
MVCs working toget her
MVCs not working toget her
Object ive-C
New language to lear n!
S t r ict super set of C
Adds syntax for classes, methods, etc.
A f ew th ings to “think different ly” about (e.g. propert ies, dynamic binding)
Most important concept to under stand today: Propert ies
Usually we do not access instance var iables direct ly in Object ive -C.
Instead, we use “propert ies.”
A “property” is ju st the combinat ion of a getter method and a setter method in a class.
The getter (usually) has the name of the property (e.g. “myValue”)
The setter’s name is “set” plus capitalized property name (e.g. “setMyValue:”)
(To make this look nice, we always use a lowercase letter as the first letter of a property name.)
We ju st call the setter to store the value we want and the getter to get it. Simple.
This is j ust your first glimpse of th is language!
We’ll go much more into the details nex t week.
Don’t get too freaked out by the syntax at this point.
Coming Up
Nex t Lect ure
More of our Card Game Model
X code 5 Demonst rat ion (start building our Card Game applicat ion)
Nex t Week
Finish off our Card Game applicat ion
Object ive-C in more detail
Foundat ion (ar ray, dict ionar y, etc.)
And much much more!
Download