Skip to content

Commit 1a5070e

Browse files
committed
finished revising appendix example
1 parent 8581a0e commit 1a5070e

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

Diff for: bk1ch14Appendix/Appendix/Thing.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
#import <Foundation/Foundation.h>
44

5-
enum state {
5+
enum State {
66
kDead,
77
kAlive
88
};
9+
typedef enum State State;
910

10-
void setState (enum state s);
11+
void setState (State s);
1112

1213
@interface Thing : NSObject
1314

Diff for: bk1ch14Appendix/Appendix/Thing.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#import "Thing.h"
44

5-
void setState (enum state s) {
5+
void setState (State s) {
66
NSLog(@"%d",s);
77
}
88

Diff for: bk1ch14Appendix/Appendix/ViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ViewController: UIViewController {
7979

8080
setState(kDead)
8181
setState(kAlive)
82-
setState(state(rawValue:2)) // Swift can't stop you
82+
setState(State(rawValue:2)) // Swift can't stop you
8383

8484
self.view.autoresizingMask = .FlexibleWidth
8585
self.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
@@ -163,13 +163,13 @@ class ViewController: UIViewController {
163163

164164
do {
165165
func f (s:String) {print(s)}
166+
// let thing = f as! AnyObject // crash
166167
let holder = StringExpecterHolder()
167168
holder.f = f
168169
let lay = CALayer()
169170
lay.setValue(holder, forKey:"myFunction")
170171
let holder2 = lay.valueForKey("myFunction") as! StringExpecterHolder
171172
holder2.f("testing")
172-
173173
}
174174

175175
}

Diff for: bk2ch14p640systemSound/ch27p910systemSound/ViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import AudioToolbox
55

66
// can be top level...
77

8-
func soundFinished(snd:SystemSoundID, _ context:UnsafeMutablePointer<Void>) -> Void {
8+
func soundFinished(snd:UInt32, _ c:UnsafeMutablePointer<Void>) -> Void {
99
print("finished!")
1010
AudioServicesRemoveSystemSoundCompletion(snd)
1111
AudioServicesDisposeSystemSoundID(snd)

0 commit comments

Comments
 (0)