Skip to content

Commit a599f1d

Browse files
committed
revised chapter 26 examples
1 parent b270b13 commit a599f1d

File tree

38 files changed

+720
-329
lines changed

38 files changed

+720
-329
lines changed

bk2ch26p878undoableDrag/ch39p1123undoableDrag.xcodeproj/project.pbxproj

Lines changed: 16 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,28 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
3268385D1BCF0B9D00A986FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3268385C1BCF0B9D00A986FF /* LaunchScreen.storyboard */; settings = {ASSET_TAGS = (); }; };
11+
3268385F1BCF0BA100A986FF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3268385E1BCF0BA100A986FF /* AppDelegate.swift */; settings = {ASSET_TAGS = (); }; };
1012
3289AB4719B4C9AB00937D0C /* MyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3289AB4619B4C9AB00937D0C /* MyView.swift */; };
11-
32942DEA183915D2003EB51A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32942DE9183915D2003EB51A /* Foundation.framework */; };
12-
32942DEC183915D2003EB51A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32942DEB183915D2003EB51A /* CoreGraphics.framework */; };
13-
32942DEE183915D2003EB51A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32942DED183915D2003EB51A /* UIKit.framework */; };
14-
32942DF4183915D2003EB51A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 32942DF2183915D2003EB51A /* InfoPlist.strings */; };
15-
32942DF6183915D2003EB51A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 32942DF5183915D2003EB51A /* main.m */; };
16-
32942DFA183915D2003EB51A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 32942DF9183915D2003EB51A /* AppDelegate.m */; };
1713
32942DFD183915D2003EB51A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32942DFB183915D2003EB51A /* Main.storyboard */; };
18-
32942E00183915D2003EB51A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 32942DFF183915D2003EB51A /* ViewController.m */; };
19-
32942E02183915D2003EB51A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32942E01183915D2003EB51A /* Images.xcassets */; };
14+
32942E02183915D2003EB51A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32942E01183915D2003EB51A /* Assets.xcassets */; };
2015
/* End PBXBuildFile section */
2116

2217
/* Begin PBXFileReference section */
18+
3268385C1BCF0B9D00A986FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
19+
3268385E1BCF0BA100A986FF /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2320
3289AB4619B4C9AB00937D0C /* MyView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyView.swift; sourceTree = "<group>"; };
2421
32942DE6183915D2003EB51A /* ch39p1123undoableDrag.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ch39p1123undoableDrag.app; sourceTree = BUILT_PRODUCTS_DIR; };
25-
32942DE9183915D2003EB51A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
26-
32942DEB183915D2003EB51A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
27-
32942DED183915D2003EB51A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
2822
32942DF1183915D2003EB51A /* ch39p1123undoableDrag-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ch39p1123undoableDrag-Info.plist"; sourceTree = "<group>"; };
29-
32942DF3183915D2003EB51A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
30-
32942DF5183915D2003EB51A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
31-
32942DF7183915D2003EB51A /* ch39p1123undoableDrag-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ch39p1123undoableDrag-Prefix.pch"; sourceTree = "<group>"; };
32-
32942DF8183915D2003EB51A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
33-
32942DF9183915D2003EB51A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
3423
32942DFC183915D2003EB51A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
35-
32942DFE183915D2003EB51A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
36-
32942DFF183915D2003EB51A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
37-
32942E01183915D2003EB51A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
38-
32942E08183915D3003EB51A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
24+
32942E01183915D2003EB51A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3925
/* End PBXFileReference section */
4026

4127
/* Begin PBXFrameworksBuildPhase section */
4228
32942DE3183915D2003EB51A /* Frameworks */ = {
4329
isa = PBXFrameworksBuildPhase;
4430
buildActionMask = 2147483647;
4531
files = (
46-
32942DEC183915D2003EB51A /* CoreGraphics.framework in Frameworks */,
47-
32942DEE183915D2003EB51A /* UIKit.framework in Frameworks */,
48-
32942DEA183915D2003EB51A /* Foundation.framework in Frameworks */,
4932
);
5033
runOnlyForDeploymentPostprocessing = 0;
5134
};
@@ -56,7 +39,6 @@
5639
isa = PBXGroup;
5740
children = (
5841
32942DEF183915D2003EB51A /* ch39p1123undoableDrag */,
59-
32942DE8183915D2003EB51A /* Frameworks */,
6042
32942DE7183915D2003EB51A /* Products */,
6143
);
6244
sourceTree = "<group>";
@@ -69,41 +51,17 @@
6951
name = Products;
7052
sourceTree = "<group>";
7153
};
72-
32942DE8183915D2003EB51A /* Frameworks */ = {
73-
isa = PBXGroup;
74-
children = (
75-
32942DE9183915D2003EB51A /* Foundation.framework */,
76-
32942DEB183915D2003EB51A /* CoreGraphics.framework */,
77-
32942DED183915D2003EB51A /* UIKit.framework */,
78-
32942E08183915D3003EB51A /* XCTest.framework */,
79-
);
80-
name = Frameworks;
81-
sourceTree = "<group>";
82-
};
8354
32942DEF183915D2003EB51A /* ch39p1123undoableDrag */ = {
8455
isa = PBXGroup;
8556
children = (
86-
32942DF8183915D2003EB51A /* AppDelegate.h */,
87-
32942DF9183915D2003EB51A /* AppDelegate.m */,
57+
3268385E1BCF0BA100A986FF /* AppDelegate.swift */,
8858
32942DFB183915D2003EB51A /* Main.storyboard */,
89-
32942DFE183915D2003EB51A /* ViewController.h */,
90-
32942DFF183915D2003EB51A /* ViewController.m */,
9159
3289AB4619B4C9AB00937D0C /* MyView.swift */,
92-
32942E01183915D2003EB51A /* Images.xcassets */,
93-
32942DF0183915D2003EB51A /* Supporting Files */,
94-
);
95-
path = ch39p1123undoableDrag;
96-
sourceTree = "<group>";
97-
};
98-
32942DF0183915D2003EB51A /* Supporting Files */ = {
99-
isa = PBXGroup;
100-
children = (
60+
32942E01183915D2003EB51A /* Assets.xcassets */,
61+
3268385C1BCF0B9D00A986FF /* LaunchScreen.storyboard */,
10162
32942DF1183915D2003EB51A /* ch39p1123undoableDrag-Info.plist */,
102-
32942DF2183915D2003EB51A /* InfoPlist.strings */,
103-
32942DF5183915D2003EB51A /* main.m */,
104-
32942DF7183915D2003EB51A /* ch39p1123undoableDrag-Prefix.pch */,
10563
);
106-
name = "Supporting Files";
64+
path = ch39p1123undoableDrag;
10765
sourceTree = "<group>";
10866
};
10967
/* End PBXGroup section */
@@ -132,6 +90,7 @@
13290
32942DDE183915D2003EB51A /* Project object */ = {
13391
isa = PBXProject;
13492
attributes = {
93+
LastSwiftUpdateCheck = 0700;
13594
LastUpgradeCheck = 0500;
13695
ORGANIZATIONNAME = "Matt Neuburg";
13796
};
@@ -158,8 +117,8 @@
158117
isa = PBXResourcesBuildPhase;
159118
buildActionMask = 2147483647;
160119
files = (
161-
32942E02183915D2003EB51A /* Images.xcassets in Resources */,
162-
32942DF4183915D2003EB51A /* InfoPlist.strings in Resources */,
120+
3268385D1BCF0B9D00A986FF /* LaunchScreen.storyboard in Resources */,
121+
32942E02183915D2003EB51A /* Assets.xcassets in Resources */,
163122
32942DFD183915D2003EB51A /* Main.storyboard in Resources */,
164123
);
165124
runOnlyForDeploymentPostprocessing = 0;
@@ -171,24 +130,14 @@
171130
isa = PBXSourcesBuildPhase;
172131
buildActionMask = 2147483647;
173132
files = (
174-
32942E00183915D2003EB51A /* ViewController.m in Sources */,
133+
3268385F1BCF0BA100A986FF /* AppDelegate.swift in Sources */,
175134
3289AB4719B4C9AB00937D0C /* MyView.swift in Sources */,
176-
32942DFA183915D2003EB51A /* AppDelegate.m in Sources */,
177-
32942DF6183915D2003EB51A /* main.m in Sources */,
178135
);
179136
runOnlyForDeploymentPostprocessing = 0;
180137
};
181138
/* End PBXSourcesBuildPhase section */
182139

183140
/* Begin PBXVariantGroup section */
184-
32942DF2183915D2003EB51A /* InfoPlist.strings */ = {
185-
isa = PBXVariantGroup;
186-
children = (
187-
32942DF3183915D2003EB51A /* en */,
188-
);
189-
name = InfoPlist.strings;
190-
sourceTree = "<group>";
191-
};
192141
32942DFB183915D2003EB51A /* Main.storyboard */ = {
193142
isa = PBXVariantGroup;
194143
children = (
@@ -233,7 +182,7 @@
233182
GCC_WARN_UNINITIALIZED_AUTOS = YES;
234183
GCC_WARN_UNUSED_FUNCTION = YES;
235184
GCC_WARN_UNUSED_VARIABLE = YES;
236-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
185+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
237186
ONLY_ACTIVE_ARCH = YES;
238187
SDKROOT = iphoneos;
239188
};
@@ -266,7 +215,7 @@
266215
GCC_WARN_UNINITIALIZED_AUTOS = YES;
267216
GCC_WARN_UNUSED_FUNCTION = YES;
268217
GCC_WARN_UNUSED_VARIABLE = YES;
269-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
218+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
270219
SDKROOT = iphoneos;
271220
VALIDATE_PRODUCT = YES;
272221
};
@@ -277,7 +226,6 @@
277226
buildSettings = {
278227
ARCHS = "$(ARCHS_STANDARD)";
279228
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
280-
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
281229
CLANG_ENABLE_MODULES = YES;
282230
GCC_PRECOMPILE_PREFIX_HEADER = YES;
283231
GCC_PREFIX_HEADER = "ch39p1123undoableDrag/ch39p1123undoableDrag-Prefix.pch";
@@ -295,7 +243,6 @@
295243
buildSettings = {
296244
ARCHS = "$(ARCHS_STANDARD)";
297245
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
298-
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
299246
CLANG_ENABLE_MODULES = YES;
300247
GCC_PRECOMPILE_PREFIX_HEADER = YES;
301248
GCC_PREFIX_HEADER = "ch39p1123undoableDrag/ch39p1123undoableDrag-Prefix.pch";

bk2ch26p878undoableDrag/ch39p1123undoableDrag/AppDelegate.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

bk2ch26p878undoableDrag/ch39p1123undoableDrag/AppDelegate.m

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import UIKit
2+
3+
@UIApplicationMain
4+
class AppDelegate : UIResponder, UIApplicationDelegate {
5+
var window : UIWindow?
6+
7+
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
8+
9+
return true
10+
}
11+
}
12+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,30 @@
55
"size" : "29x29",
66
"scale" : "2x"
77
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "29x29",
11+
"scale" : "3x"
12+
},
813
{
914
"idiom" : "iphone",
1015
"size" : "40x40",
1116
"scale" : "2x"
1217
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "40x40",
21+
"scale" : "3x"
22+
},
1323
{
1424
"idiom" : "iphone",
1525
"size" : "60x60",
1626
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "60x60",
31+
"scale" : "3x"
1732
}
1833
],
1934
"info" : {

bk2ch26p878undoableDrag/ch39p1123undoableDrag/Base.lproj/Main.storyboard

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6206.8" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7026.1"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
55
</dependencies>
66
<scenes>
77
<!--View Controller-->
88
<scene sceneID="ufC-wZ-h7g">
99
<objects>
10-
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
10+
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="ch39p1123undoableDrag" customModuleProvider="target" sceneMemberID="viewController">
1111
<layoutGuides>
1212
<viewControllerLayoutGuide type="top" id="LKo-1q-b1Y"/>
1313
<viewControllerLayoutGuide type="bottom" id="LJB-QY-TIF"/>
@@ -28,12 +28,4 @@
2828
</objects>
2929
</scene>
3030
</scenes>
31-
<simulatedMetricsContainer key="defaultSimulatedMetrics">
32-
<simulatedStatusBarMetrics key="statusBar"/>
33-
<simulatedOrientationMetrics key="orientation"/>
34-
<simulatedScreenMetrics key="destination" type="retina4">
35-
<size key="portraitSize" width="320" height="568"/>
36-
<size key="landscapeSize" width="568" height="320"/>
37-
</simulatedScreenMetrics>
38-
</simulatedMetricsContainer>
3931
</document>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
6+
</dependencies>
7+
<scenes>
8+
<!--View Controller-->
9+
<scene sceneID="EHf-IW-A2E">
10+
<objects>
11+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
12+
<layoutGuides>
13+
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
14+
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
15+
</layoutGuides>
16+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
17+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
20+
</view>
21+
</viewController>
22+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
23+
</objects>
24+
<point key="canvasLocation" x="53" y="375"/>
25+
</scene>
26+
</scenes>
27+
</document>

bk2ch26p878undoableDrag/ch39p1123undoableDrag/MyView.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import UIKit
44

5+
class ViewController : UIViewController {
6+
7+
}
8+
59
class MyView : UIView {
610

711
let undoer = NSUndoManager()
8-
override var undoManager : NSUndoManager {
9-
get {
10-
return self.undoer
11-
}
12+
override var undoManager : NSUndoManager? {
13+
return self.undoer
1214
}
1315

1416
override func awakeFromNib() {
@@ -29,9 +31,7 @@ class MyView : UIView {
2931
object: NSValue(CGPoint:self.center))
3032
self.undoer.setActionName("Move")
3133
if self.undoer.undoing || self.undoer.redoing {
32-
// println("here")
33-
// let opt = UIViewAnimationOptions.BeginFromCurrentState // not needed in iOS 8?
34-
UIView.animateWithDuration(0.4, delay: 0.1, options: nil, animations: {
34+
UIView.animateWithDuration(0.4, delay: 0.1, options: [], animations: {
3535
self.center = newCenter.CGPointValue()
3636
}, completion: nil)
3737
} else {

bk2ch26p878undoableDrag/ch39p1123undoableDrag/ViewController.h

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)