Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Class 02 Objective C
1. Class 2 – Introduction to Objective C
• MVC – Model View Controller is an architectural pattern that splits
interactions between users and applications into three roles:
Controller
(User input)
View Model
(User interface) (business logic)
• Model - What your application is (but not how it is displayed).
• Controller - How your Model is presented to the user (UI).
• View – Your Controller’s minions.
2. MVC - Model View Controller
Controller
(User input)
View Model
(User interface) (business logic)
It’s all about managing communication between
camps.
3. MVC - Model View Controller
Controller
(User input)
View Model
(User interface) (business logic)
Controllers can always talk directly to their Model
Controllers can also talk directly to their View
The Model and View should never speak to each other.
4. MVC - Model View Controller
Controller
? (User input)
View Model
(User interface) (business logic)
Can View speak to its Controller?
Sort of. Communications is “BLIND” and structured.
5. MVC - Model View Controller
target
Controller
(User input)
action
View Model
(User interface) (business logic)
The Controller can drop a target on itself.
Then hand out, an action to the View.
6. MVC - Model View Controller
target Controller
(User input)
action
View Model
(User interface) (business logic)
will
should did
Sometimes the View needs to synchronize with the Controller.
7. MVC - Model View Controller
did
will
target Controller should
(User input)
action
View Model
(User interface) (business logic)
The Controller sets itself as the View’s delegate.
The delegate is set via a protocol (i.e. it’s “blind” to class).
Views don’t own the data they display.
So, if needed, they have a protocol to acquire it.
8. MVC - Model View Controller
did
target will
count Controller should
data at (User input)
action
View Model
(User interface) (business logic)
Controllers are almost always that data source (not Model).
Controllers interpret/format Model information for the View.
9. MVC - Model View Controller
did
target will
count Controller should
data at (User input)
?
action
View Model
(User interface) (business logic)
Can the model talk directly to the Controller?
No. The Model is (should be) IU independent.
10. MVC - Model View Controller
did
target will
count Controller should
data at (User input)
Notification &
KVO
action
View Model
(User interface) (business logic)
So what if the Model has information to update or something?.
It uses a “radio station” – like broadcast mechanism.
11. MVC - Model View Controller
did
target will
count Controller should
data at (User input)
Notification &
KVO
action
View Model
(User interface) (business logic)
Controllers (or other Model) “tune in” to interesting stuff.
A View might “tune in”, but probably not to a Model’s “station”.
Now combine MVC groups to make complicated programs… :P
12. Objective C
• New language to learn
– Stick superset of C
– Adds syntax for classes, methods, etc.
– A few things to “Think differently” about (e.g. properties, dynamic binding).
• Most important concept to understand today: Properties.
– Usually we don’t access instance variables directly in Objective-C.
– Instead, we use “properties”.
– A “property” is just the combination of a getter method and a setter method in a class.
– The getter has the name of the property (e.g. “myValue”)
– The setter’s name is “set” plus capitalized property name (e.g. “setMyValye”)
(To make this look nice, we always use a lowercase letter as the first letter of property name.)
We just call the setter to store the values we want and the getter to get it. Simple!!
• This is just your fist glimpse of this language
– We’ll go much more into the details next class.
– Don’t get too freaked out by the syntax at this point ;)