TODAY
NEXT WEEK (or so)
Check out Sample Code at http://git.io/ve9gE
This code needs changes (as it is pre Swift 1.2)
f: a function which returns an Array or NIL
func f(arr: [Int]) -> [Int]? { if (arr.count < 1) { return nil } else { return arr }
}
Array? is of type OPTIONAL (yes that's a type) Use UNWRAPPING via ! to get the actual value
var i = f([1,2])![0] //OK - unwrapping works var i = f([1])![0] //Booom - f returns NIL
Typical pattern.
if (let i = f([1]) { println(i.description) }
You can also use
if (f(<some array>) != nil) { // do something }
Delegation is a design pattern that enables a class or structure to hand off (or delegate) some of its responsibilities to an instance of another type.
Application Delegate. - viewDidLoad CLLocationManagerDelegate.
There are important events in the life of your application that happen out of its direct control. These include things like launching and terminating. Your application needs to know when these things happen or are about to happen, so the iPhone OS will automatically notify your AppDelegate by calling the appropriate method (e.g. applicationDidFinishLaunching, applicationWillTerminate). That's the main purpose of the AppDelegate.
Things that should be run once a BLE event is triggered.
Responding to Location Events Pausing Location Updates Responding to Region Events Responding to Authorization Changes
This app will not be accepted by Apple.