1. pyanfield
  2. ProCoreData

Commits

pyanfield  committed bff7986

chapter 5. p169. first part has finished. but second not.

  • Participants
  • Parent commits 57e1a2f
  • Branches default

Comments (0)

Files changed (20)

File .DS_Store

  • Ignore whitespace
Binary file modified.

File chapter5/Shapes/Shapes.xcodeproj/project.pbxproj

View file
  • Ignore whitespace
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		902BAD1F1490EC6F00B3001A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 902BAD1E1490EC6F00B3001A /* UIKit.framework */; };
+		902BAD211490EC6F00B3001A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 902BAD201490EC6F00B3001A /* Foundation.framework */; };
+		902BAD231490EC6F00B3001A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 902BAD221490EC6F00B3001A /* CoreGraphics.framework */; };
+		902BAD291490EC6F00B3001A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 902BAD271490EC6F00B3001A /* InfoPlist.strings */; };
+		902BAD2B1490EC6F00B3001A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 902BAD2A1490EC6F00B3001A /* main.m */; };
+		902BAD2F1490EC6F00B3001A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 902BAD2E1490EC6F00B3001A /* AppDelegate.m */; };
+		902BAD321490EC6F00B3001A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 902BAD311490EC6F00B3001A /* ViewController.m */; };
+		902BAD351490EC6F00B3001A /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 902BAD331490EC6F00B3001A /* ViewController.xib */; };
+		902BAD3C1490EC9600B3001A /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 902BAD3B1490EC9600B3001A /* CoreData.framework */; };
+		90EF63111490ED2F0027D2C5 /* Shapes.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 90EF630F1490ED2F0027D2C5 /* Shapes.xcdatamodeld */; };
+		90EF63151490FFD30027D2C5 /* BasicCanvasUIView.m in Sources */ = {isa = PBXBuildFile; fileRef = 90EF63141490FFD30027D2C5 /* BasicCanvasUIView.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+		902BAD1A1490EC6E00B3001A /* Shapes.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Shapes.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		902BAD1E1490EC6F00B3001A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+		902BAD201490EC6F00B3001A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+		902BAD221490EC6F00B3001A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+		902BAD261490EC6F00B3001A /* Shapes-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Shapes-Info.plist"; sourceTree = "<group>"; };
+		902BAD281490EC6F00B3001A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		902BAD2A1490EC6F00B3001A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+		902BAD2C1490EC6F00B3001A /* Shapes-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Shapes-Prefix.pch"; sourceTree = "<group>"; };
+		902BAD2D1490EC6F00B3001A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+		902BAD2E1490EC6F00B3001A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+		902BAD301490EC6F00B3001A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
+		902BAD311490EC6F00B3001A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
+		902BAD341490EC6F00B3001A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = "<group>"; };
+		902BAD3B1490EC9600B3001A /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
+		90EF63101490ED2F0027D2C5 /* Shapes.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Shapes.xcdatamodel; sourceTree = "<group>"; };
+		90EF63131490FFD30027D2C5 /* BasicCanvasUIView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasicCanvasUIView.h; sourceTree = "<group>"; };
+		90EF63141490FFD30027D2C5 /* BasicCanvasUIView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasicCanvasUIView.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		902BAD171490EC6E00B3001A /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				902BAD3C1490EC9600B3001A /* CoreData.framework in Frameworks */,
+				902BAD1F1490EC6F00B3001A /* UIKit.framework in Frameworks */,
+				902BAD211490EC6F00B3001A /* Foundation.framework in Frameworks */,
+				902BAD231490EC6F00B3001A /* CoreGraphics.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		902BAD0F1490EC6E00B3001A = {
+			isa = PBXGroup;
+			children = (
+				902BAD241490EC6F00B3001A /* Shapes */,
+				902BAD1D1490EC6E00B3001A /* Frameworks */,
+				902BAD1B1490EC6E00B3001A /* Products */,
+			);
+			sourceTree = "<group>";
+		};
+		902BAD1B1490EC6E00B3001A /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				902BAD1A1490EC6E00B3001A /* Shapes.app */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		902BAD1D1490EC6E00B3001A /* Frameworks */ = {
+			isa = PBXGroup;
+			children = (
+				902BAD3B1490EC9600B3001A /* CoreData.framework */,
+				902BAD1E1490EC6F00B3001A /* UIKit.framework */,
+				902BAD201490EC6F00B3001A /* Foundation.framework */,
+				902BAD221490EC6F00B3001A /* CoreGraphics.framework */,
+			);
+			name = Frameworks;
+			sourceTree = "<group>";
+		};
+		902BAD241490EC6F00B3001A /* Shapes */ = {
+			isa = PBXGroup;
+			children = (
+				902BAD2D1490EC6F00B3001A /* AppDelegate.h */,
+				902BAD2E1490EC6F00B3001A /* AppDelegate.m */,
+				902BAD301490EC6F00B3001A /* ViewController.h */,
+				902BAD311490EC6F00B3001A /* ViewController.m */,
+				902BAD331490EC6F00B3001A /* ViewController.xib */,
+				902BAD251490EC6F00B3001A /* Supporting Files */,
+				90EF63131490FFD30027D2C5 /* BasicCanvasUIView.h */,
+				90EF63141490FFD30027D2C5 /* BasicCanvasUIView.m */,
+			);
+			path = Shapes;
+			sourceTree = "<group>";
+		};
+		902BAD251490EC6F00B3001A /* Supporting Files */ = {
+			isa = PBXGroup;
+			children = (
+				902BAD261490EC6F00B3001A /* Shapes-Info.plist */,
+				902BAD271490EC6F00B3001A /* InfoPlist.strings */,
+				902BAD2A1490EC6F00B3001A /* main.m */,
+				902BAD2C1490EC6F00B3001A /* Shapes-Prefix.pch */,
+				90EF630F1490ED2F0027D2C5 /* Shapes.xcdatamodeld */,
+			);
+			name = "Supporting Files";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		902BAD191490EC6E00B3001A /* Shapes */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 902BAD381490EC6F00B3001A /* Build configuration list for PBXNativeTarget "Shapes" */;
+			buildPhases = (
+				902BAD161490EC6E00B3001A /* Sources */,
+				902BAD171490EC6E00B3001A /* Frameworks */,
+				902BAD181490EC6E00B3001A /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = Shapes;
+			productName = Shapes;
+			productReference = 902BAD1A1490EC6E00B3001A /* Shapes.app */;
+			productType = "com.apple.product-type.application";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		902BAD111490EC6E00B3001A /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0420;
+				ORGANIZATIONNAME = pyanfield;
+			};
+			buildConfigurationList = 902BAD141490EC6E00B3001A /* Build configuration list for PBXProject "Shapes" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = 902BAD0F1490EC6E00B3001A;
+			productRefGroup = 902BAD1B1490EC6E00B3001A /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				902BAD191490EC6E00B3001A /* Shapes */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		902BAD181490EC6E00B3001A /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				902BAD291490EC6F00B3001A /* InfoPlist.strings in Resources */,
+				902BAD351490EC6F00B3001A /* ViewController.xib in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		902BAD161490EC6E00B3001A /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				902BAD2B1490EC6F00B3001A /* main.m in Sources */,
+				902BAD2F1490EC6F00B3001A /* AppDelegate.m in Sources */,
+				902BAD321490EC6F00B3001A /* ViewController.m in Sources */,
+				90EF63111490ED2F0027D2C5 /* Shapes.xcdatamodeld in Sources */,
+				90EF63151490FFD30027D2C5 /* BasicCanvasUIView.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+		902BAD271490EC6F00B3001A /* InfoPlist.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				902BAD281490EC6F00B3001A /* en */,
+			);
+			name = InfoPlist.strings;
+			sourceTree = "<group>";
+		};
+		902BAD331490EC6F00B3001A /* ViewController.xib */ = {
+			isa = PBXVariantGroup;
+			children = (
+				902BAD341490EC6F00B3001A /* en */,
+			);
+			name = ViewController.xib;
+			sourceTree = "<group>";
+		};
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+		902BAD361490EC6F00B3001A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				CLANG_ENABLE_OBJC_ARC = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+				SDKROOT = iphoneos;
+				TARGETED_DEVICE_FAMILY = 2;
+			};
+			name = Debug;
+		};
+		902BAD371490EC6F00B3001A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				CLANG_ENABLE_OBJC_ARC = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				COPY_PHASE_STRIP = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+				OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+				SDKROOT = iphoneos;
+				TARGETED_DEVICE_FAMILY = 2;
+				VALIDATE_PRODUCT = YES;
+			};
+			name = Release;
+		};
+		902BAD391490EC6F00B3001A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "Shapes/Shapes-Prefix.pch";
+				INFOPLIST_FILE = "Shapes/Shapes-Info.plist";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				WRAPPER_EXTENSION = app;
+			};
+			name = Debug;
+		};
+		902BAD3A1490EC6F00B3001A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = "Shapes/Shapes-Prefix.pch";
+				INFOPLIST_FILE = "Shapes/Shapes-Info.plist";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				WRAPPER_EXTENSION = app;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		902BAD141490EC6E00B3001A /* Build configuration list for PBXProject "Shapes" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				902BAD361490EC6F00B3001A /* Debug */,
+				902BAD371490EC6F00B3001A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		902BAD381490EC6F00B3001A /* Build configuration list for PBXNativeTarget "Shapes" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				902BAD391490EC6F00B3001A /* Debug */,
+				902BAD3A1490EC6F00B3001A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+
+/* Begin XCVersionGroup section */
+		90EF630F1490ED2F0027D2C5 /* Shapes.xcdatamodeld */ = {
+			isa = XCVersionGroup;
+			children = (
+				90EF63101490ED2F0027D2C5 /* Shapes.xcdatamodel */,
+			);
+			currentVersion = 90EF63101490ED2F0027D2C5 /* Shapes.xcdatamodel */;
+			path = Shapes.xcdatamodeld;
+			sourceTree = "<group>";
+			versionGroupType = wrapper.xcdatamodel;
+		};
+/* End XCVersionGroup section */
+	};
+	rootObject = 902BAD111490EC6E00B3001A /* Project object */;
+}

File chapter5/Shapes/Shapes.xcodeproj/project.xcworkspace/contents.xcworkspacedata

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+   version = "1.0">
+   <FileRef
+      location = "self:Shapes.xcodeproj">
+   </FileRef>
+</Workspace>

File chapter5/Shapes/Shapes.xcodeproj/project.xcworkspace/xcuserdata/pyanfield.xcuserdatad/UserInterfaceState.xcuserstate

  • Ignore whitespace
Binary file added.

File chapter5/Shapes/Shapes.xcodeproj/xcuserdata/pyanfield.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+   type = "1"
+   version = "1.0">
+   <FileBreakpoints>
+      <FileBreakpoint
+         shouldBeEnabled = "No"
+         ignoreCount = "0"
+         continueAfterRunningActions = "No"
+         isPathRelative = "1"
+         filePath = "Shapes/ViewController.m"
+         timestampString = "345477789.890275"
+         startingColumnNumber = "9223372036854775807"
+         endingColumnNumber = "9223372036854775807"
+         startingLineNumber = "213"
+         endingLineNumber = "213"
+         landmarkName = "-touchesBegan:withEvent:"
+         landmarkType = "5">
+      </FileBreakpoint>
+   </FileBreakpoints>
+</Bucket>

File chapter5/Shapes/Shapes.xcodeproj/xcuserdata/pyanfield.xcuserdatad/xcschemes/Shapes.xcscheme

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "902BAD191490EC6E00B3001A"
+               BuildableName = "Shapes.app"
+               BlueprintName = "Shapes"
+               ReferencedContainer = "container:Shapes.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      buildConfiguration = "Debug">
+      <Testables>
+      </Testables>
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "902BAD191490EC6E00B3001A"
+            BuildableName = "Shapes.app"
+            BlueprintName = "Shapes"
+            ReferencedContainer = "container:Shapes.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+   </TestAction>
+   <LaunchAction
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      buildConfiguration = "Debug"
+      debugDocumentVersioning = "YES"
+      allowLocationSimulation = "YES">
+      <BuildableProductRunnable>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "902BAD191490EC6E00B3001A"
+            BuildableName = "Shapes.app"
+            BlueprintName = "Shapes"
+            ReferencedContainer = "container:Shapes.xcodeproj">
+         </BuildableReference>
+      </BuildableProductRunnable>
+      <AdditionalOptions>
+      </AdditionalOptions>
+   </LaunchAction>
+   <ProfileAction
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      buildConfiguration = "Release"
+      debugDocumentVersioning = "YES">
+      <BuildableProductRunnable>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "902BAD191490EC6E00B3001A"
+            BuildableName = "Shapes.app"
+            BlueprintName = "Shapes"
+            ReferencedContainer = "container:Shapes.xcodeproj">
+         </BuildableReference>
+      </BuildableProductRunnable>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

File chapter5/Shapes/Shapes.xcodeproj/xcuserdata/pyanfield.xcuserdatad/xcschemes/xcschememanagement.plist

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>SchemeUserState</key>
+	<dict>
+		<key>Shapes.xcscheme</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>0</integer>
+		</dict>
+	</dict>
+	<key>SuppressBuildableAutocreation</key>
+	<dict>
+		<key>902BAD191490EC6E00B3001A</key>
+		<dict>
+			<key>primary</key>
+			<true/>
+		</dict>
+	</dict>
+</dict>
+</plist>

File chapter5/Shapes/Shapes/AppDelegate.h

View file
  • Ignore whitespace
+//
+//  AppDelegate.h
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <CoreData/CoreData.h>
+
+@class ViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+{
+    NSManagedObjectContext* __managedObjectContext;
+    NSManagedObjectModel* __managedObjectModel;
+    NSPersistentStoreCoordinator* __persistentStoreCoordinator;
+    
+}
+
+@property (strong, nonatomic) UIWindow *window;
+@property (strong, nonatomic) ViewController *viewController;
+
+@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
+@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
+@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
+
+@end

File chapter5/Shapes/Shapes/AppDelegate.m

View file
  • Ignore whitespace
+//
+//  AppDelegate.m
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+#import "ViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+
+@synthesize managedObjectModel = __managedObjectModel;
+@synthesize managedObjectContext = __managedObjectContext;
+@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+    // Override point for customization after application launch.
+    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
+    
+    // init the managedObjectContext to ViewController
+    self.viewController.managedObjectContext = self.managedObjectContext;
+    
+    self.window.rootViewController = self.viewController;
+    [self.window makeKeyAndVisible];
+    return YES;
+}
+
+#pragma mark - Core Data stack
+
+- (NSManagedObjectModel*)managedObjectModel
+{
+    if(__managedObjectModel != nil)
+    {
+        return __managedObjectModel;
+    }
+    __managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
+    return __managedObjectModel;
+    
+}
+
+- (NSPersistentStoreCoordinator*)persistentStoreCoordinator
+{
+    if (__persistentStoreCoordinator != nil) {
+        return __persistentStoreCoordinator;
+    }
+    
+    NSString *dir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
+    
+    NSURL *storeURL = [NSURL fileURLWithPath:[dir stringByAppendingPathComponent:@"Shapes.sqlite"]];
+    
+    NSError *error = nil;
+    
+    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
+    
+    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
+        NSLog(@"Unresolved error %@, %@",error,[error userInfo]);
+        abort();
+    }
+    return __persistentStoreCoordinator;
+}
+
+- (NSManagedObjectContext*)managedObjectContext
+{
+    if (__managedObjectContext != nil) {
+        return __managedObjectContext;
+    }
+    
+    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
+    if (coordinator != nil) {
+        __managedObjectContext = [[NSManagedObjectContext alloc] init];
+        [__managedObjectContext setPersistentStoreCoordinator:coordinator];
+    }
+    
+    return __managedObjectContext;
+}
+
+
+
+
+
+
+@end

File chapter5/Shapes/Shapes/BasicCanvasUIView.h

View file
  • Ignore whitespace
+//
+//  BasicCanvasUIView.h
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import <CoreData/CoreData.h>
+
+@interface BasicCanvasUIView : UIView
+{
+    NSManagedObject* _canvas;
+}
+
+@property (nonatomic,strong) NSManagedObject *canvas;
+
+- (float)scale;
+@end

File chapter5/Shapes/Shapes/BasicCanvasUIView.m

View file
  • Ignore whitespace
+//
+//  BasicCanvasUIView.m
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import "BasicCanvasUIView.h"
+
+@implementation BasicCanvasUIView
+
+@synthesize canvas = _canvas;
+
+- (float)scale
+{
+    NSManagedObject *transform = [self.canvas valueForKey:@"transform"];
+    return [[transform valueForKey:@"scale"] floatValue];
+}
+
+//p153 override the drawRect method to redraw the view content.
+- (void)drawRect:(CGRect)rect
+{
+    
+    NSLog(@">> BasicCanvasUIView drawRect");
+    if (self.canvas == nil) {
+        return;
+    }
+    
+    CGContextRef context = UIGraphicsGetCurrentContext();
+    float scale = self.scale;
+    CGContextScaleCTM(context, scale, scale);
+    //retrieve al the shapes that relate to this canvas and iterate through them
+    NSSet *shapes = [self.canvas valueForKey:@"shapes"];
+    for (NSManagedObject *shape in shapes) {
+        NSString *entityName = [[shape entity] name];
+        
+        NSString *colorCode = [shape valueForKey:@"color"];
+        NSArray *colorCodes = [colorCode componentsSeparatedByString:@","];
+        
+        CGContextSetRGBFillColor(context, [[colorCodes objectAtIndex:0] floatValue]/255,[[colorCodes objectAtIndex:1] floatValue]/255,[[colorCodes objectAtIndex:2] floatValue]/255,1.0);
+        //if this shape is Circle
+        if ([entityName compare:@"Circle"] == NSOrderedSame) {
+            float x = [[shape valueForKey:@"x"] floatValue];
+            float y = [[shape valueForKey:@"y"] floatValue];
+            float radius = [[shape valueForKey:@"radius"] floatValue];
+            
+            CGContextFillEllipseInRect(context, CGRectMake(x-radius, y-radius, 2*radius, 2*radius));
+        }else if([entityName compare:@"Polygon"] == NSOrderedSame)
+        {
+            NSSortDescriptor *sortDesciptor = [[NSSortDescriptor alloc] initWithKey:@"index" ascending:YES];
+            NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDesciptor,nil];
+            NSArray *vertices = [[[shape mutableSetValueForKey:@"vertices"] allObjects] sortedArrayUsingDescriptors:sortDescriptors];
+            
+            // begin drawing the polygon
+            
+            CGContextBeginPath(context);
+            NSManagedObject *lastVertex = [vertices lastObject];
+            CGContextMoveToPoint(context, [[lastVertex valueForKey:@"x"] floatValue], [[lastVertex valueForKey:@"y"] floatValue]);
+            for(NSManagedObject *vertext in vertices){
+                CGContextAddLineToPoint(context, [[vertext valueForKey:@"x"] floatValue], [[vertext valueForKey:@"y"] floatValue]);
+            }
+            
+            CGContextFillPath(context);
+        }
+    }
+}
+
+
+
+
+@end

File chapter5/Shapes/Shapes/Shapes-Info.plist

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleDisplayName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundleExecutable</key>
+	<string>${EXECUTABLE_NAME}</string>
+	<key>CFBundleIconFiles</key>
+	<array/>
+	<key>CFBundleIdentifier</key>
+	<string>test.pyanfield.${PRODUCT_NAME:rfc1034identifier}</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1.0</string>
+	<key>LSRequiresIPhoneOS</key>
+	<true/>
+	<key>UIRequiredDeviceCapabilities</key>
+	<array>
+		<string>armv7</string>
+	</array>
+	<key>UISupportedInterfaceOrientations~ipad</key>
+	<array>
+		<string>UIInterfaceOrientationPortrait</string>
+		<string>UIInterfaceOrientationPortraitUpsideDown</string>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
+		<string>UIInterfaceOrientationLandscapeRight</string>
+	</array>
+</dict>
+</plist>

File chapter5/Shapes/Shapes/Shapes-Prefix.pch

View file
  • Ignore whitespace
+//
+// Prefix header for all source files of the 'Shapes' target in the 'Shapes' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_4_0
+#warning "This project uses features only available in iOS SDK 4.0 and later."
+#endif
+
+#ifdef __OBJC__
+    #import <UIKit/UIKit.h>
+    #import <Foundation/Foundation.h>
+#endif

File chapter5/Shapes/Shapes/Shapes.xcdatamodeld/.xccurrentversion

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>_XCCurrentVersionName</key>
+	<string>Shapes.xcdatamodel</string>
+</dict>
+</plist>

File chapter5/Shapes/Shapes/Shapes.xcdatamodeld/Shapes.xcdatamodel/contents

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<model name="" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="872" systemVersion="11C74" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic">
+    <entity name="Canvas" syncable="YES">
+        <relationship name="shapes" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Shape" inverseName="canvases" inverseEntity="Shape" syncable="YES"/>
+        <relationship name="transform" minCount="1" maxCount="1" deletionRule="Cascade" destinationEntity="Transform" inverseName="canvas" inverseEntity="Transform" syncable="YES"/>
+    </entity>
+    <entity name="Circle" parentEntity="Shape" syncable="YES">
+        <attribute name="radius" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
+        <attribute name="x" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
+        <attribute name="y" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
+    </entity>
+    <entity name="Polygon" parentEntity="Shape" syncable="YES">
+        <relationship name="vertices" toMany="YES" minCount="3" deletionRule="Cascade" destinationEntity="Vertex" inverseName="polygon" inverseEntity="Vertex" syncable="YES"/>
+    </entity>
+    <entity name="Shape" syncable="YES">
+        <attribute name="color" attributeType="String" syncable="YES"/>
+        <relationship name="canvases" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Canvas" inverseName="shapes" inverseEntity="Canvas" syncable="YES"/>
+    </entity>
+    <entity name="Transform" syncable="YES">
+        <attribute name="scale" optional="YES" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
+        <relationship name="canvas" minCount="1" maxCount="1" deletionRule="Deny" destinationEntity="Canvas" inverseName="transform" inverseEntity="Canvas" syncable="YES"/>
+    </entity>
+    <entity name="Vertex" syncable="YES">
+        <attribute name="index" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
+        <attribute name="x" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
+        <attribute name="y" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
+        <relationship name="polygon" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="Polygon" inverseName="vertices" inverseEntity="Polygon" syncable="YES"/>
+    </entity>
+    <elements>
+        <element name="Canvas" positionX="403" positionY="123" width="128" height="75"/>
+        <element name="Circle" positionX="288" positionY="243" width="128" height="90"/>
+        <element name="Polygon" positionX="115" positionY="219" width="128" height="60"/>
+        <element name="Shape" positionX="205" positionY="108" width="128" height="75"/>
+        <element name="Transform" positionX="432" positionY="366" width="128" height="75"/>
+        <element name="Vertex" positionX="108" positionY="354" width="128" height="105"/>
+    </elements>
+</model>

File chapter5/Shapes/Shapes/ViewController.h

View file
  • Ignore whitespace
+//
+//  ViewController.h
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "BasicCanvasUIView.h"
+#import <CoreData/CoreData.h>
+
+@interface ViewController : UIViewController
+{
+    NSManagedObjectContext* __managedObjectContext;
+    IBOutlet BasicCanvasUIView* _topView;
+    IBOutlet BasicCanvasUIView* _bottomView;
+}
+
+@property (nonatomic,strong) BasicCanvasUIView *topView;
+@property (nonatomic,strong) BasicCanvasUIView *bottomView;
+@property (nonatomic,strong) NSManagedObjectContext *managedObjectContext;
+@end

File chapter5/Shapes/Shapes/ViewController.m

View file
  • Ignore whitespace
+//
+//  ViewController.m
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import "ViewController.h"
+#import <stdlib.h>
+
+@interface ViewController()
+- (void)createShapeAt:(CGPoint)point;
+- (void)updateAllShapes;
+- (void)deleteAllShapes;
+- (NSString*)makeRandomColor;
+@end
+
+
+@implementation ViewController
+
+@synthesize topView = _topView;
+@synthesize bottomView = _bottomView;
+@synthesize managedObjectContext = __managedObjectContext;
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+    // Return YES for supported orientations
+    return YES;
+}
+
+//p166
+- (void)viewDidLoad
+{
+    NSLog(@"ViewController viewDidLoad");
+    NSManagedObject *canvas1 = nil;
+    NSManagedObject *canvas2 = nil;
+    
+    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
+    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Canvas" inManagedObjectContext:self.managedObjectContext];
+    
+    [fetchRequest setEntity:entity];
+    NSArray *canvases = [self.managedObjectContext executeFetchRequest:fetchRequest error:nil];
+    
+    //if canvases already exist in the persistent store. load them
+    if ([canvases count]>=2) {
+        NSLog(@"Canvase existing,londing them now");
+        canvas1 = [canvases objectAtIndex:0];
+        canvas2 = [canvases objectAtIndex:1];
+    }else
+    {
+        NSLog(@"Making new Canvases");
+        canvas1 = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
+        canvas2 = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
+        
+        
+        NSManagedObject *transfome1 = [NSEntityDescription insertNewObjectForEntityForName:@"Transform" inManagedObjectContext:self.managedObjectContext];
+        [transfome1 setValue:[NSNumber numberWithFloat:1] forKey:@"scale"];
+        [canvas1 setValue:transfome1 forKey:@"transform"];
+        
+        NSManagedObject *transform2 = [NSEntityDescription insertNewObjectForEntityForName:@"Transform" inManagedObjectContext:self.managedObjectContext];
+        [transform2 setValue:[NSNumber numberWithFloat:0.5] forKey:@"scale"];
+        [canvas2 setValue:transform2 forKey:@"transform"];
+        
+        
+        //save the context
+        NSError *error = nil;
+        if (![self.managedObjectContext save:&error]) {
+            NSLog(@"Save Canvases Failed %@,%@",error,[error userInfo]);
+            abort();
+        }
+        
+        self.topView.canvas = canvas1;
+        self.bottomView.canvas = canvas2;
+        
+    }
+}
+
+#pragma mark - ViewController Private Methods
+- (void)createShapeAt:(CGPoint)point
+{
+    NSManagedObject *shape = nil;
+    
+    //Randomly choose a Circle or a Polygon
+    int type = arc4random()%2;
+    
+    if(type == 0)
+    {
+        //Circle
+        NSEntityDescription *entity = [NSEntityDescription entityForName:@"Circle" inManagedObjectContext:self.managedObjectContext];
+        NSManagedObject *circle = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
+        
+        shape = circle;
+        float radius = 10+(arc4random()%90);
+        [circle setValue:[NSNumber numberWithFloat:point.x] forKey:@"x"];
+        [circle setValue:[NSNumber numberWithFloat:point.y] forKey:@"y"];
+        [circle setValue:[NSNumber numberWithFloat:radius] forKey:@"radius"];
+        
+        NSLog(@"Made a Circle at (%f,%f) with radius %f",point.x,point.y,radius);
+    }else
+    {
+        NSEntityDescription *entity = [NSEntityDescription entityForName:@"Polygon" inManagedObjectContext:self.managedObjectContext];
+        NSManagedObject *polygon = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
+        
+        shape = polygon;
+        
+        NSMutableSet *vertices = [polygon mutableSetValueForKey:@"vertices"];
+        
+        int nVertices = 3+(arc4random()%20);
+        float angleIncrement = (2*M_PI)/nVertices;
+        
+        int index = 0;
+        for (float i = 0; i<nVertices; i++) {
+            float a = i*angleIncrement;
+            float radius = 10+(arc4random()%90);
+            float x = point.x + (radius*cos(a));
+            float y = point.y + (radius*sin(a));
+            
+            NSEntityDescription *vertexEntity = [NSEntityDescription entityForName:@"Vertex" inManagedObjectContext:self.managedObjectContext];
+            NSManagedObject *vertex = [NSEntityDescription insertNewObjectForEntityForName:[vertexEntity name] inManagedObjectContext:self.managedObjectContext];
+            
+            [vertex setValue:[NSNumber numberWithFloat:x] forKey:@"x"];
+            [vertex setValue:[NSNumber numberWithFloat:y] forKey:@"y"];
+            [vertex setValue:[NSNumber numberWithInt:index] forKey:@"index"];
+            
+            [vertices addObject:vertex];
+        }
+        NSLog(@"made a new polygon with %d vertices",nVertices);
+    }
+    
+    [shape setValue:[self makeRandomColor] forKey:@"color"];
+    
+    [[self.topView.canvas mutableSetValueForKey:@"shapes"] addObject:shape];
+    [[self.bottomView.canvas mutableSetValueForKey:@"shapes"] addObject:shape];
+    
+    NSError *error = nil;
+    if(![self.managedObjectContext save:&error])
+    {
+        NSLog(@"Unresolved error %@,%@",error,[error userInfo]);
+        abort();
+    }
+    
+    //tell the view to repaint themselves
+    [self.topView setNeedsDisplay];
+    [self.bottomView setNeedsDisplay];
+    
+}
+
+//p164
+- (NSString*)makeRandomColor
+{
+    int red = arc4random()%256;
+    int green = arc4random()%256;
+    int blue = arc4random()%256;
+    
+    return [NSString stringWithFormat:@"%d,%d,%d",red,green,blue];
+}
+
+- (void)updateAllShapes
+{
+    //retrieve all shapes
+    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
+    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Shape" inManagedObjectContext:self.managedObjectContext];
+    [fetchRequest setEntity:entity];
+    NSArray *shapes = [self.managedObjectContext executeFetchRequest:fetchRequest error:nil];
+    
+    for (NSManagedObject *shape in shapes) {
+        [shape setValue:[self makeRandomColor] forKey:@"color"];
+    }
+    
+    //save context
+    NSError *error = nil;
+    if (![self.managedObjectContext save:&error]) {
+        NSLog(@"Unresolved error %@,%@",error,[error userInfo]);
+        abort();
+    }
+    
+    [self.topView setNeedsDisplay];
+    [self.bottomView setNeedsDisplay];
+}
+
+- (void)deleteAllShapes
+{
+    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
+    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Shape" inManagedObjectContext:self.managedObjectContext];
+    [fetchRequest setEntity:entity];
+    
+    NSArray *shapes = [self.managedObjectContext executeFetchRequest:fetchRequest error:nil];
+    
+    for (NSManagedObject *shape in shapes) {
+        [self.managedObjectContext deleteObject:shape];
+    }
+    
+    NSError *error = nil;
+    if (![self.managedObjectContext save:&error]) {
+        NSLog(@"Unresolved error %@,%@",error,[error userInfo]);
+        abort();
+    }
+    
+    [self.topView setNeedsDisplay];
+    [self.bottomView setNeedsDisplay];
+}
+
+#pragma mark - Touch Events Handling
+
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+    UITouch *touch = [touches anyObject];
+    
+    CGPoint location = [touch locationInView:touch.view];
+    
+    //scale according to the canvas' transform
+    float scale = [(BasicCanvasUIView*)touch.view scale];
+    location = CGPointMake(location.x/scale, location.y/scale);
+    NSLog(@"Touch Event At (%f,%f,%f)",location.x,location.y,scale);
+    //create the shape
+    [self createShapeAt:location];
+}
+
+//rotate the view
+- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
+{
+    [self updateAllShapes];
+}
+
+- (BOOL)canBecomeFirstResponder
+{
+    return YES;
+}
+
+- (void)viewDidAppear:(BOOL)animated
+{
+    [super viewDidAppear:animated];
+    [self becomeFirstResponder];
+}
+
+#pragma mark - Shake Events Handling
+- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
+{
+    if (event.subtype == UIEventSubtypeMotionShake) {
+        [self deleteAllShapes];
+    }
+}
+@end

File chapter5/Shapes/Shapes/en.lproj/InfoPlist.strings

View file
  • Ignore whitespace
+/* Localized versions of Info.plist keys */
+

File chapter5/Shapes/Shapes/en.lproj/ViewController.xib

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
+	<data>
+		<int key="IBDocument.SystemTarget">1280</int>
+		<string key="IBDocument.SystemVersion">11C74</string>
+		<string key="IBDocument.InterfaceBuilderVersion">1938</string>
+		<string key="IBDocument.AppKitVersion">1138.23</string>
+		<string key="IBDocument.HIToolboxVersion">567.00</string>
+		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+			<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			<string key="NS.object.0">933</string>
+		</object>
+		<array key="IBDocument.IntegratedClassDependencies">
+			<string>IBProxyObject</string>
+			<string>IBUIView</string>
+		</array>
+		<array key="IBDocument.PluginDependencies">
+			<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+		</array>
+		<object class="NSMutableDictionary" key="IBDocument.Metadata">
+			<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+			<integer value="1" key="NS.object.0"/>
+		</object>
+		<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+			<object class="IBProxyObject" id="841351856">
+				<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+				<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+			</object>
+			<object class="IBProxyObject" id="606714003">
+				<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+				<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+			</object>
+			<object class="IBUIView" id="766721923">
+				<reference key="NSNextResponder"/>
+				<int key="NSvFlags">274</int>
+				<array class="NSMutableArray" key="NSSubviews">
+					<object class="IBUIView" id="91818796">
+						<reference key="NSNextResponder" ref="766721923"/>
+						<int key="NSvFlags">306</int>
+						<string key="NSFrameSize">{768, 502}</string>
+						<reference key="NSSuperview" ref="766721923"/>
+						<reference key="NSWindow"/>
+						<reference key="NSNextKeyView" ref="470737464"/>
+						<string key="NSReuseIdentifierKey">_NS:212</string>
+						<object class="NSColor" key="IBUIBackgroundColor" id="887450475">
+							<int key="NSColorSpace">3</int>
+							<bytes key="NSWhite">MQA</bytes>
+						</object>
+						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+					</object>
+					<object class="IBUIView" id="470737464">
+						<reference key="NSNextResponder" ref="766721923"/>
+						<int key="NSvFlags">282</int>
+						<string key="NSFrame">{{0, 502}, {768, 502}}</string>
+						<reference key="NSSuperview" ref="766721923"/>
+						<reference key="NSWindow"/>
+						<reference key="NSNextKeyView"/>
+						<string key="NSReuseIdentifierKey">_NS:212</string>
+						<reference key="IBUIBackgroundColor" ref="887450475"/>
+						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+					</object>
+				</array>
+				<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
+				<reference key="NSSuperview"/>
+				<reference key="NSWindow"/>
+				<reference key="NSNextKeyView" ref="91818796"/>
+				<object class="NSColor" key="IBUIBackgroundColor">
+					<int key="NSColorSpace">3</int>
+					<bytes key="NSWhite">MQA</bytes>
+					<object class="NSColorSpace" key="NSCustomColorSpace">
+						<int key="NSID">2</int>
+					</object>
+				</object>
+				<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics">
+					<int key="IBUIStatusBarStyle">2</int>
+				</object>
+				<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+			</object>
+		</array>
+		<object class="IBObjectContainer" key="IBDocument.Objects">
+			<array class="NSMutableArray" key="connectionRecords">
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">view</string>
+						<reference key="source" ref="841351856"/>
+						<reference key="destination" ref="766721923"/>
+					</object>
+					<int key="connectionID">3</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">_topView</string>
+						<reference key="source" ref="841351856"/>
+						<reference key="destination" ref="91818796"/>
+					</object>
+					<int key="connectionID">5</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">_bottomView</string>
+						<reference key="source" ref="841351856"/>
+						<reference key="destination" ref="470737464"/>
+					</object>
+					<int key="connectionID">7</int>
+				</object>
+			</array>
+			<object class="IBMutableOrderedSet" key="objectRecords">
+				<array key="orderedObjects">
+					<object class="IBObjectRecord">
+						<int key="objectID">0</int>
+						<array key="object" id="0"/>
+						<reference key="children" ref="1000"/>
+						<nil key="parent"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-1</int>
+						<reference key="object" ref="841351856"/>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">File's Owner</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-2</int>
+						<reference key="object" ref="606714003"/>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">2</int>
+						<reference key="object" ref="766721923"/>
+						<array class="NSMutableArray" key="children">
+							<reference ref="91818796"/>
+							<reference ref="470737464"/>
+						</array>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">4</int>
+						<reference key="object" ref="91818796"/>
+						<reference key="parent" ref="766721923"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">6</int>
+						<reference key="object" ref="470737464"/>
+						<reference key="parent" ref="766721923"/>
+					</object>
+				</array>
+			</object>
+			<dictionary class="NSMutableDictionary" key="flattenedProperties">
+				<string key="-1.CustomClassName">ViewController</string>
+				<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="-2.CustomClassName">UIResponder</string>
+				<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="4.CustomClassName">BasicCanvasUIView</string>
+				<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="6.CustomClassName">BasicCanvasUIView</string>
+				<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			</dictionary>
+			<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+			<nil key="activeLocalization"/>
+			<dictionary class="NSMutableDictionary" key="localizations"/>
+			<nil key="sourceID"/>
+			<int key="maxID">7</int>
+		</object>
+		<object class="IBClassDescriber" key="IBDocument.Classes">
+			<array class="NSMutableArray" key="referencedPartialClassDescriptions">
+				<object class="IBPartialClassDescription">
+					<string key="className">BasicCanvasUIView</string>
+					<string key="superclassName">UIView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/BasicCanvasUIView.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">ViewController</string>
+					<string key="superclassName">UIViewController</string>
+					<dictionary class="NSMutableDictionary" key="outlets">
+						<string key="_bottomView">BasicCanvasUIView</string>
+						<string key="_topView">BasicCanvasUIView</string>
+					</dictionary>
+					<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+						<object class="IBToOneOutletInfo" key="_bottomView">
+							<string key="name">_bottomView</string>
+							<string key="candidateClassName">BasicCanvasUIView</string>
+						</object>
+						<object class="IBToOneOutletInfo" key="_topView">
+							<string key="name">_topView</string>
+							<string key="candidateClassName">BasicCanvasUIView</string>
+						</object>
+					</dictionary>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/ViewController.h</string>
+					</object>
+				</object>
+			</array>
+		</object>
+		<int key="IBDocument.localizationMode">0</int>
+		<string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
+		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+		<int key="IBDocument.defaultPropertyAccessControl">3</int>
+		<string key="IBCocoaTouchPluginVersion">933</string>
+	</data>
+</archive>

File chapter5/Shapes/Shapes/main.m

View file
  • Ignore whitespace
+//
+//  main.m
+//  Shapes
+//
+//  Created by han pyanfield on 11-12-8.
+//  Copyright (c) 2011年 pyanfield. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+    @autoreleasepool {
+        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+    }
+}