Skip to content

Commit e70f0f7

Browse files
committed
tweaks to chapter 12 examples; in particular, show new block-based timer
1 parent 28bfd6e commit e70f0f7

File tree

22 files changed

+585
-3
lines changed

22 files changed

+585
-3
lines changed

bk1ch12p490autoreleasepool/bk1ch12p490autoreleasepool.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
TargetAttributes = {
9999
32FFD39E1B5A9B080055D1E0 = {
100100
CreatedOnToolsVersion = 7.0;
101+
DevelopmentTeam = W3LHX5RGV2;
102+
DevelopmentTeamName = "Matt Neuburg";
101103
LastSwiftMigration = 0800;
102104
};
103105
};
@@ -252,6 +254,7 @@
252254
buildSettings = {
253255
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
254256
INFOPLIST_FILE = bk1ch12p490autoreleasepool/Info.plist;
257+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
255258
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
256259
PRODUCT_BUNDLE_IDENTIFIER = com.neuburg.matt.bk1ch12p490autoreleasepool;
257260
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -264,6 +267,7 @@
264267
buildSettings = {
265268
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
266269
INFOPLIST_FILE = bk1ch12p490autoreleasepool/Info.plist;
270+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
267271
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
268272
PRODUCT_BUNDLE_IDENTIFIER = com.neuburg.matt.bk1ch12p490autoreleasepool;
269273
PRODUCT_NAME = "$(TARGET_NAME)";

bk1ch12p498timerLeaker/ch12p325NotificationLeaker/FlipsideViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ class FlipsideViewController: UIViewController {
1515
override func viewWillAppear(_ animated: Bool) {
1616
super.viewWillAppear(animated)
1717
print("starting timer")
18-
self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(dummy), userInfo: nil, repeats: true)
18+
self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(fired), userInfo: nil, repeats: true)
1919
self.timer.tolerance = 0.1
2020
}
2121

22-
func dummy(_ t:Timer) {
22+
func fired(_ t:Timer) {
2323
print("timer fired")
2424
}
2525

2626
override func viewDidDisappear(_ animated: Bool) {
2727
super.viewDidDisappear(animated)
2828
// return; // uncomment and we will leak
2929
print("invalidate")
30-
self.timer?.invalidate()
30+
self.timer.invalidate()
3131
}
3232

3333
@IBAction func done (_ sender:AnyObject!) {
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
32EF65231A86744C00E5150E /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32EF65221A86744C00E5150E /* MainViewController.swift */; };
11+
32EF65251A8676CF00E5150E /* FlipsideViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32EF65241A8676CF00E5150E /* FlipsideViewController.swift */; };
12+
32FFD3BB1B5AAD140055D1E0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32FFD3BA1B5AAD140055D1E0 /* LaunchScreen.storyboard */; };
13+
32FFD3BD1B5AAD480055D1E0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32FFD3BC1B5AAD480055D1E0 /* AppDelegate.swift */; };
14+
C9E8B38717A0307B0000C352 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9E8B38517A0307B0000C352 /* Main.storyboard */; };
15+
C9E8B38F17A0307B0000C352 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9E8B38E17A0307B0000C352 /* Assets.xcassets */; };
16+
/* End PBXBuildFile section */
17+
18+
/* Begin PBXFileReference section */
19+
32EF65221A86744C00E5150E /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
20+
32EF65241A8676CF00E5150E /* FlipsideViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlipsideViewController.swift; sourceTree = "<group>"; };
21+
32FFD3BA1B5AAD140055D1E0 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
22+
32FFD3BC1B5AAD480055D1E0 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
23+
C9E8B37017A0307B0000C352 /* ch12p325NotificationLeaker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ch12p325NotificationLeaker.app; sourceTree = BUILT_PRODUCTS_DIR; };
24+
C9E8B37B17A0307B0000C352 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
25+
C9E8B38617A0307B0000C352 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
26+
C9E8B38E17A0307B0000C352 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
27+
/* End PBXFileReference section */
28+
29+
/* Begin PBXFrameworksBuildPhase section */
30+
C9E8B36D17A0307B0000C352 /* Frameworks */ = {
31+
isa = PBXFrameworksBuildPhase;
32+
buildActionMask = 2147483647;
33+
files = (
34+
);
35+
runOnlyForDeploymentPostprocessing = 0;
36+
};
37+
/* End PBXFrameworksBuildPhase section */
38+
39+
/* Begin PBXGroup section */
40+
C9E8B36717A0307B0000C352 = {
41+
isa = PBXGroup;
42+
children = (
43+
C9E8B37917A0307B0000C352 /* ch12p325NotificationLeaker */,
44+
C9E8B37117A0307B0000C352 /* Products */,
45+
);
46+
sourceTree = "<group>";
47+
};
48+
C9E8B37117A0307B0000C352 /* Products */ = {
49+
isa = PBXGroup;
50+
children = (
51+
C9E8B37017A0307B0000C352 /* ch12p325NotificationLeaker.app */,
52+
);
53+
name = Products;
54+
sourceTree = "<group>";
55+
};
56+
C9E8B37917A0307B0000C352 /* ch12p325NotificationLeaker */ = {
57+
isa = PBXGroup;
58+
children = (
59+
C9E8B38517A0307B0000C352 /* Main.storyboard */,
60+
32FFD3BC1B5AAD480055D1E0 /* AppDelegate.swift */,
61+
32EF65221A86744C00E5150E /* MainViewController.swift */,
62+
32EF65241A8676CF00E5150E /* FlipsideViewController.swift */,
63+
C9E8B38E17A0307B0000C352 /* Assets.xcassets */,
64+
32FFD3BA1B5AAD140055D1E0 /* LaunchScreen.storyboard */,
65+
C9E8B37B17A0307B0000C352 /* Info.plist */,
66+
);
67+
path = ch12p325NotificationLeaker;
68+
sourceTree = "<group>";
69+
};
70+
/* End PBXGroup section */
71+
72+
/* Begin PBXNativeTarget section */
73+
C9E8B36F17A0307B0000C352 /* ch12p325NotificationLeaker */ = {
74+
isa = PBXNativeTarget;
75+
buildConfigurationList = C9E8B3A517A0307B0000C352 /* Build configuration list for PBXNativeTarget "ch12p325NotificationLeaker" */;
76+
buildPhases = (
77+
C9E8B36C17A0307B0000C352 /* Sources */,
78+
C9E8B36D17A0307B0000C352 /* Frameworks */,
79+
C9E8B36E17A0307B0000C352 /* Resources */,
80+
);
81+
buildRules = (
82+
);
83+
dependencies = (
84+
);
85+
name = ch12p325NotificationLeaker;
86+
productName = ch12p325NotificationLeaker;
87+
productReference = C9E8B37017A0307B0000C352 /* ch12p325NotificationLeaker.app */;
88+
productType = "com.apple.product-type.application";
89+
};
90+
/* End PBXNativeTarget section */
91+
92+
/* Begin PBXProject section */
93+
C9E8B36817A0307B0000C352 /* Project object */ = {
94+
isa = PBXProject;
95+
attributes = {
96+
LastSwiftUpdateCheck = 0700;
97+
LastUpgradeCheck = 0500;
98+
ORGANIZATIONNAME = "Matt Neuburg";
99+
TargetAttributes = {
100+
C9E8B36F17A0307B0000C352 = {
101+
LastSwiftMigration = 0800;
102+
};
103+
};
104+
};
105+
buildConfigurationList = C9E8B36B17A0307B0000C352 /* Build configuration list for PBXProject "ch12p325NotificationLeaker" */;
106+
compatibilityVersion = "Xcode 3.2";
107+
developmentRegion = English;
108+
hasScannedForEncodings = 0;
109+
knownRegions = (
110+
en,
111+
Base,
112+
);
113+
mainGroup = C9E8B36717A0307B0000C352;
114+
productRefGroup = C9E8B37117A0307B0000C352 /* Products */;
115+
projectDirPath = "";
116+
projectRoot = "";
117+
targets = (
118+
C9E8B36F17A0307B0000C352 /* ch12p325NotificationLeaker */,
119+
);
120+
};
121+
/* End PBXProject section */
122+
123+
/* Begin PBXResourcesBuildPhase section */
124+
C9E8B36E17A0307B0000C352 /* Resources */ = {
125+
isa = PBXResourcesBuildPhase;
126+
buildActionMask = 2147483647;
127+
files = (
128+
32FFD3BB1B5AAD140055D1E0 /* LaunchScreen.storyboard in Resources */,
129+
C9E8B38F17A0307B0000C352 /* Assets.xcassets in Resources */,
130+
C9E8B38717A0307B0000C352 /* Main.storyboard in Resources */,
131+
);
132+
runOnlyForDeploymentPostprocessing = 0;
133+
};
134+
/* End PBXResourcesBuildPhase section */
135+
136+
/* Begin PBXSourcesBuildPhase section */
137+
C9E8B36C17A0307B0000C352 /* Sources */ = {
138+
isa = PBXSourcesBuildPhase;
139+
buildActionMask = 2147483647;
140+
files = (
141+
32FFD3BD1B5AAD480055D1E0 /* AppDelegate.swift in Sources */,
142+
32EF65251A8676CF00E5150E /* FlipsideViewController.swift in Sources */,
143+
32EF65231A86744C00E5150E /* MainViewController.swift in Sources */,
144+
);
145+
runOnlyForDeploymentPostprocessing = 0;
146+
};
147+
/* End PBXSourcesBuildPhase section */
148+
149+
/* Begin PBXVariantGroup section */
150+
C9E8B38517A0307B0000C352 /* Main.storyboard */ = {
151+
isa = PBXVariantGroup;
152+
children = (
153+
C9E8B38617A0307B0000C352 /* Base */,
154+
);
155+
name = Main.storyboard;
156+
sourceTree = "<group>";
157+
};
158+
/* End PBXVariantGroup section */
159+
160+
/* Begin XCBuildConfiguration section */
161+
C9E8B3A317A0307B0000C352 /* Debug */ = {
162+
isa = XCBuildConfiguration;
163+
buildSettings = {
164+
ALWAYS_SEARCH_USER_PATHS = NO;
165+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
166+
CLANG_CXX_LIBRARY = "libc++";
167+
CLANG_ENABLE_MODULES = YES;
168+
CLANG_ENABLE_OBJC_ARC = YES;
169+
CLANG_WARN_BOOL_CONVERSION = YES;
170+
CLANG_WARN_CONSTANT_CONVERSION = YES;
171+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
172+
CLANG_WARN_EMPTY_BODY = YES;
173+
CLANG_WARN_ENUM_CONVERSION = YES;
174+
CLANG_WARN_INT_CONVERSION = YES;
175+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
176+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
177+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
178+
COPY_PHASE_STRIP = NO;
179+
GCC_C_LANGUAGE_STANDARD = gnu99;
180+
GCC_DYNAMIC_NO_PIC = NO;
181+
GCC_OPTIMIZATION_LEVEL = 0;
182+
GCC_PREPROCESSOR_DEFINITIONS = (
183+
"DEBUG=1",
184+
"$(inherited)",
185+
);
186+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
187+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
188+
GCC_WARN_UNDECLARED_SELECTOR = YES;
189+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
190+
GCC_WARN_UNUSED_FUNCTION = YES;
191+
GCC_WARN_UNUSED_VARIABLE = YES;
192+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
193+
ONLY_ACTIVE_ARCH = YES;
194+
SDKROOT = iphoneos;
195+
};
196+
name = Debug;
197+
};
198+
C9E8B3A417A0307B0000C352 /* Release */ = {
199+
isa = XCBuildConfiguration;
200+
buildSettings = {
201+
ALWAYS_SEARCH_USER_PATHS = NO;
202+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
203+
CLANG_CXX_LIBRARY = "libc++";
204+
CLANG_ENABLE_MODULES = YES;
205+
CLANG_ENABLE_OBJC_ARC = YES;
206+
CLANG_WARN_BOOL_CONVERSION = YES;
207+
CLANG_WARN_CONSTANT_CONVERSION = YES;
208+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
209+
CLANG_WARN_EMPTY_BODY = YES;
210+
CLANG_WARN_ENUM_CONVERSION = YES;
211+
CLANG_WARN_INT_CONVERSION = YES;
212+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
213+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
214+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
215+
COPY_PHASE_STRIP = YES;
216+
ENABLE_NS_ASSERTIONS = NO;
217+
GCC_C_LANGUAGE_STANDARD = gnu99;
218+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
219+
GCC_WARN_UNDECLARED_SELECTOR = YES;
220+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
221+
GCC_WARN_UNUSED_FUNCTION = YES;
222+
GCC_WARN_UNUSED_VARIABLE = YES;
223+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
224+
SDKROOT = iphoneos;
225+
VALIDATE_PRODUCT = YES;
226+
};
227+
name = Release;
228+
};
229+
C9E8B3A617A0307B0000C352 /* Debug */ = {
230+
isa = XCBuildConfiguration;
231+
buildSettings = {
232+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
233+
CLANG_ENABLE_MODULES = YES;
234+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
235+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
236+
GCC_PREFIX_HEADER = "ch12p325NotificationLeaker/ch12p325NotificationLeaker-Prefix.pch";
237+
INFOPLIST_FILE = ch12p325NotificationLeaker/Info.plist;
238+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
239+
PRODUCT_NAME = "$(TARGET_NAME)";
240+
SWIFT_OBJC_BRIDGING_HEADER = "";
241+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
242+
SWIFT_VERSION = 3.0;
243+
WRAPPER_EXTENSION = app;
244+
};
245+
name = Debug;
246+
};
247+
C9E8B3A717A0307B0000C352 /* Release */ = {
248+
isa = XCBuildConfiguration;
249+
buildSettings = {
250+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
251+
CLANG_ENABLE_MODULES = YES;
252+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
253+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
254+
GCC_PREFIX_HEADER = "ch12p325NotificationLeaker/ch12p325NotificationLeaker-Prefix.pch";
255+
INFOPLIST_FILE = ch12p325NotificationLeaker/Info.plist;
256+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
257+
PRODUCT_NAME = "$(TARGET_NAME)";
258+
SWIFT_OBJC_BRIDGING_HEADER = "";
259+
SWIFT_VERSION = 3.0;
260+
WRAPPER_EXTENSION = app;
261+
};
262+
name = Release;
263+
};
264+
/* End XCBuildConfiguration section */
265+
266+
/* Begin XCConfigurationList section */
267+
C9E8B36B17A0307B0000C352 /* Build configuration list for PBXProject "ch12p325NotificationLeaker" */ = {
268+
isa = XCConfigurationList;
269+
buildConfigurations = (
270+
C9E8B3A317A0307B0000C352 /* Debug */,
271+
C9E8B3A417A0307B0000C352 /* Release */,
272+
);
273+
defaultConfigurationIsVisible = 0;
274+
defaultConfigurationName = Release;
275+
};
276+
C9E8B3A517A0307B0000C352 /* Build configuration list for PBXNativeTarget "ch12p325NotificationLeaker" */ = {
277+
isa = XCConfigurationList;
278+
buildConfigurations = (
279+
C9E8B3A617A0307B0000C352 /* Debug */,
280+
C9E8B3A717A0307B0000C352 /* Release */,
281+
);
282+
defaultConfigurationIsVisible = 0;
283+
defaultConfigurationName = Release;
284+
};
285+
/* End XCConfigurationList section */
286+
};
287+
rootObject = C9E8B36817A0307B0000C352 /* Project object */;
288+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import UIKit
3+
4+
@UIApplicationMain
5+
class AppDelegate : UIResponder, UIApplicationDelegate {
6+
var window : UIWindow?
7+
8+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]? = [:]) -> Bool {
9+
10+
return true
11+
}
12+
}

0 commit comments

Comments
 (0)