Skip to content

Commit

Permalink
new material for Xcode 7 beta 5
Browse files Browse the repository at this point in the history
  • Loading branch information
mattneub committed Aug 8, 2015
1 parent 58b481f commit a06dcb8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bk1ch04p132enums/bk1ch04p132enums/ViewController.swift
Expand Up @@ -78,6 +78,12 @@ class ViewController: UIViewController {
case .Fatal(let theNumber, let theMessage):
print("number: \(theNumber), message: \(theMessage)")
}

do {
let fatalMaker = Error2.Fatal
let err = fatalMaker(n:-1000, s:"Unbelievably bad error")
_ = err
}

switch s {
case .Some(let theString):
Expand Down
Expand Up @@ -112,6 +112,35 @@ class NoisyDog9 : Dog9 {
super.init(name:"Fido", license:123)
return nil // _now_ you are allowed to fail
}
// illegal: init? cannot override init
// override init?(name:String, license:Int) {
// super.init(name:name, license:license)
// }
override init(name:String, license:Int) {
super.init(name:name, license:license)
}
}
class ObnoxiousDog9 : NoisyDog9 {
// legal, init can override init?
override init(ok:Bool) {
super.init(name:"Fido", license:123)
}
}
class CrazyDog9 : NoisyDog9 {
override init(ok:Bool) {
super.init(ok:ok)! // legal: call super's designated init? without ? and by adding !
}
}

class A:NSObject {
init?(ok:Bool) {
super.init()
}
}
class B:A {
override init(ok:Bool) {
super.init(ok:ok)!
}
}


Expand Down
12 changes: 12 additions & 0 deletions bk1ch05p240error/bk1ch05p241error/ViewController.swift
Expand Up @@ -13,6 +13,14 @@ enum MySecondError : ErrorType {
case SecondFatalMistake
}

struct SomeStruct : ErrorType {

}
struct SomeClass : ErrorType {

}


class ViewController: UIViewController {

var ok = true
Expand All @@ -39,6 +47,10 @@ class ViewController: UIViewController {
print(error)
}

var err = SomeStruct()
print(err._domain)
print(err._code)

}

func test() {
Expand Down

0 comments on commit a06dcb8

Please sign in to comment.