After speaking to many developers in the Los Angeles area, they all reccomended I take Stanford’s “Developing iOS 9 Apps with Swift” course to solidify my iOS Development. As I watch the lectures I’ll write down my notes here.
Stanford: Applying MVC
Object-Oriented Design pattern Divide objects in your program into 3 “camps” Model and View NEVER talk to each other
What our application does
How your Model is presented to the user (UI Logic) Can always talk directly to their Model Controllers also talk directly to their view Interpreter between Model and View
View communicating with Controller
The controller can drop a target on itself via IBAction The view can call IBAction The controller sets itself as the View’s delegate “Controller is the views boss” The controller is also the data source
Controller communicating with Model
Model can’t communicate with Controller Controller is UI Logic and Model is UI Independent If model has data that changes we use a “radio station” A radio station broadcasts info when something interesting happens, the controller tunes in.
All properties and functions are public by default. This mean that other classes can call them by default.
We can make properties and functions private by adding the
private keyword before the declaration.
It’s a lot easier to make something private first then to start it off as public because when you change it to private in the future you might not know how much code relies on it.
In the assistant editor you can choose to view
Generated Interfaces to see what is available publicly.
Pass by reference vs Pass by Value
Classes are pass by reference Enums and structs are pass by value
Pass by Refernence
thing by reference means that
thing lives in the memory so when you pass it around to methods we’re passing a pointer. This means that everyone is using the same
Pass by Value
When you pass
thing by value.
thing is copied. So if we pass
thing and modify
thing the original copy is unchanged but the second copy is changed.