From 59992972e0ee0073054f01035c67a70a9efeacea Mon Sep 17 00:00:00 2001 From: Joe Blau Date: Fri, 30 Dec 2016 01:05:10 -0500 Subject: [PATCH] Fixes #25 --- .gitignore | 87 +++++++++++++++++-- ExampleSwift/Podfile | 7 +- ExampleSwift/Podfile.lock | 8 +- .../TouchVisualizer.xcodeproj/project.pbxproj | 67 +++++++++----- .../TouchVisualizer/AppDelegate.swift | 23 ++--- ExampleSwift/TouchVisualizer/Info.plist | 2 +- .../MasterViewController.swift | 40 ++++----- ExampleSwift/TouchVisualizerTests/Info.plist | 2 +- .../TouchVisualizerTests.swift | 2 +- 9 files changed, 171 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index 4d9d129..edd777d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,41 @@ -# OS X -.DS_Store +# Created by https://www.gitignore.io/api/osx,swift + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Swift ### # Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated build/ +DerivedData/ + +## Various settings *.pbxuser !default.pbxuser *.mode1v3 @@ -11,11 +44,53 @@ build/ !default.mode2v3 *.perspectivev3 !default.perspectivev3 -xcuserdata -*.xccheckout -profile +xcuserdata/ + +## Other *.moved-aside -DerivedData +*.xcuserstate + +## Obj-C/Swift specific *.hmap *.ipa +*.dSYM.zip +*.dSYM +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output + +# End of https://www.gitignore.io/api/osx,swift diff --git a/ExampleSwift/Podfile b/ExampleSwift/Podfile index 72c7265..3f3bd28 100644 --- a/ExampleSwift/Podfile +++ b/ExampleSwift/Podfile @@ -1,3 +1,6 @@ -use_frameworks! -pod "COSTouchVisualizer", :path => "../COSTouchVisualizer.podspec" +target 'TouchVisualizer' do + use_frameworks! + pod "COSTouchVisualizer", :path => "../COSTouchVisualizer.podspec" + +end diff --git a/ExampleSwift/Podfile.lock b/ExampleSwift/Podfile.lock index 7bd4e3b..26d0581 100644 --- a/ExampleSwift/Podfile.lock +++ b/ExampleSwift/Podfile.lock @@ -6,9 +6,11 @@ DEPENDENCIES: EXTERNAL SOURCES: COSTouchVisualizer: - :path: ../COSTouchVisualizer.podspec + :path: "../COSTouchVisualizer.podspec" SPEC CHECKSUMS: - COSTouchVisualizer: a398089327a6c02897823614d7447ccc97198997 + COSTouchVisualizer: 248b8645474a13d7698dd0223dc593051bf715c9 -COCOAPODS: 0.36.3 +PODFILE CHECKSUM: 562a1d56fdbb1c3ffe7f33d733b00986362d22c3 + +COCOAPODS: 1.1.1 diff --git a/ExampleSwift/TouchVisualizer.xcodeproj/project.pbxproj b/ExampleSwift/TouchVisualizer.xcodeproj/project.pbxproj index 69d5a8e..ccdda0e 100644 --- a/ExampleSwift/TouchVisualizer.xcodeproj/project.pbxproj +++ b/ExampleSwift/TouchVisualizer.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 48B6F48B525A1218DB1C0B37 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 692C5A73FFA5073B9F8A428A /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + E367FB6E6C95861F08193CDD /* Pods_TouchVisualizer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 722C6B75F43A050C04DC95BE /* Pods_TouchVisualizer.framework */; }; EDE2852D1B0AD212003CE61C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE2852C1B0AD212003CE61C /* AppDelegate.swift */; }; EDE2852F1B0AD212003CE61C /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE2852E1B0AD212003CE61C /* MasterViewController.swift */; }; EDE285311B0AD212003CE61C /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE285301B0AD212003CE61C /* DetailViewController.swift */; }; @@ -28,9 +28,10 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 1F1FC1F0F44BD641E4A32D49 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + 2083F4F7F0D125488876BD65 /* Pods-TouchVisualizer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TouchVisualizer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TouchVisualizer/Pods-TouchVisualizer.debug.xcconfig"; sourceTree = ""; }; 692C5A73FFA5073B9F8A428A /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 7170F01F6808414657FBFC43 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 722C6B75F43A050C04DC95BE /* Pods_TouchVisualizer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TouchVisualizer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 889BE90D3C110891ABA6720E /* Pods-TouchVisualizer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TouchVisualizer.release.xcconfig"; path = "Pods/Target Support Files/Pods-TouchVisualizer/Pods-TouchVisualizer.release.xcconfig"; sourceTree = ""; }; EDE285271B0AD212003CE61C /* TouchVisualizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TouchVisualizer.app; sourceTree = BUILT_PRODUCTS_DIR; }; EDE2852B1B0AD212003CE61C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; EDE2852C1B0AD212003CE61C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -49,7 +50,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 48B6F48B525A1218DB1C0B37 /* Pods.framework in Frameworks */, + E367FB6E6C95861F08193CDD /* Pods_TouchVisualizer.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -63,11 +64,11 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 411328E27CB9CBA13F7D2E51 /* Pods */ = { + 0270693985C161FC7D9CD410 /* Pods */ = { isa = PBXGroup; children = ( - 1F1FC1F0F44BD641E4A32D49 /* Pods.debug.xcconfig */, - 7170F01F6808414657FBFC43 /* Pods.release.xcconfig */, + 2083F4F7F0D125488876BD65 /* Pods-TouchVisualizer.debug.xcconfig */, + 889BE90D3C110891ABA6720E /* Pods-TouchVisualizer.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -76,6 +77,7 @@ isa = PBXGroup; children = ( 692C5A73FFA5073B9F8A428A /* Pods.framework */, + 722C6B75F43A050C04DC95BE /* Pods_TouchVisualizer.framework */, ); name = Frameworks; sourceTree = ""; @@ -86,8 +88,8 @@ EDE285291B0AD212003CE61C /* TouchVisualizer */, EDE285411B0AD212003CE61C /* TouchVisualizerTests */, EDE285281B0AD212003CE61C /* Products */, - 411328E27CB9CBA13F7D2E51 /* Pods */, 81A7636BA9229631986F594A /* Frameworks */, + 0270693985C161FC7D9CD410 /* Pods */, ); sourceTree = ""; }; @@ -146,12 +148,12 @@ isa = PBXNativeTarget; buildConfigurationList = EDE285481B0AD212003CE61C /* Build configuration list for PBXNativeTarget "TouchVisualizer" */; buildPhases = ( - 38DAE73D13D18D0F98015BA6 /* Check Pods Manifest.lock */, + 5D936C3EE9A79ADB16541756 /* [CP] Check Pods Manifest.lock */, EDE285231B0AD212003CE61C /* Sources */, EDE285241B0AD212003CE61C /* Frameworks */, EDE285251B0AD212003CE61C /* Resources */, - A0C7744E6D17892D5A1933BF /* Copy Pods Resources */, - 8860C933B1544A1B9F6B6908 /* Embed Pods Frameworks */, + 6A6C8F5202B9B365F96AEAED /* [CP] Embed Pods Frameworks */, + 4449974F51F5CC2B2C1767C3 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -186,14 +188,17 @@ EDE2851F1B0AD212003CE61C /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = Conopsys; TargetAttributes = { EDE285261B0AD212003CE61C = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = K78G42H4U2; + LastSwiftMigration = 0820; }; EDE2853D1B0AD212003CE61C = { CreatedOnToolsVersion = 6.3.1; + LastSwiftMigration = 0820; TestTargetID = EDE285261B0AD212003CE61C; }; }; @@ -238,49 +243,49 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 38DAE73D13D18D0F98015BA6 /* Check Pods Manifest.lock */ = { + 4449974F51F5CC2B2C1767C3 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TouchVisualizer/Pods-TouchVisualizer-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 8860C933B1544A1B9F6B6908 /* Embed Pods Frameworks */ = { + 5D936C3EE9A79ADB16541756 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - A0C7744E6D17892D5A1933BF /* Copy Pods Resources */ = { + 6A6C8F5202B9B365F96AEAED /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TouchVisualizer/Pods-TouchVisualizer-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -347,14 +352,17 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -391,8 +399,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -411,29 +421,36 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; }; EDE285491B0AD212003CE61C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1F1FC1F0F44BD641E4A32D49 /* Pods.debug.xcconfig */; + baseConfigurationReference = 2083F4F7F0D125488876BD65 /* Pods-TouchVisualizer.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = K78G42H4U2; INFOPLIST_FILE = TouchVisualizer/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.conopsys.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; EDE2854A1B0AD212003CE61C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7170F01F6808414657FBFC43 /* Pods.release.xcconfig */; + baseConfigurationReference = 889BE90D3C110891ABA6720E /* Pods-TouchVisualizer.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = K78G42H4U2; INFOPLIST_FILE = TouchVisualizer/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.conopsys.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -451,7 +468,9 @@ ); INFOPLIST_FILE = TouchVisualizerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.conopsys.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TouchVisualizer.app/TouchVisualizer"; }; name = Debug; @@ -466,7 +485,9 @@ ); INFOPLIST_FILE = TouchVisualizerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.conopsys.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TouchVisualizer.app/TouchVisualizer"; }; name = Release; diff --git a/ExampleSwift/TouchVisualizer/AppDelegate.swift b/ExampleSwift/TouchVisualizer/AppDelegate.swift index b04ca81..e9196c5 100644 --- a/ExampleSwift/TouchVisualizer/AppDelegate.swift +++ b/ExampleSwift/TouchVisualizer/AppDelegate.swift @@ -12,35 +12,38 @@ import COSTouchVisualizer @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, COSTouchVisualizerWindowDelegate { - lazy var window: UIWindow? = { - var customWindow = COSTouchVisualizerWindow(frame: UIScreen.mainScreen().bounds) + internal var window: UIWindow? = { + let customWindow = COSTouchVisualizerWindow(frame: UIScreen.main.bounds) - customWindow.fillColor = UIColor.purpleColor() - customWindow.strokeColor = UIColor.blueColor() + customWindow.fillColor = UIColor.purple + customWindow.strokeColor = UIColor.blue customWindow.touchAlpha = 0.4; - customWindow.rippleFillColor = UIColor.purpleColor() - customWindow.rippleStrokeColor = UIColor.blueColor() + customWindow.rippleFillColor = UIColor.purple + customWindow.rippleStrokeColor = UIColor.blue customWindow.touchAlpha = 0.1; - customWindow.touchVisualizerWindowDelegate = self return customWindow }() - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + guard let window = window as? COSTouchVisualizerWindow else { + return false + } + window.touchVisualizerWindowDelegate = self return true } // MARK: - COSTouchVisualizerWindowDelegate - func touchVisualizerWindowShouldAlwaysShowFingertip(window: COSTouchVisualizerWindow!) -> Bool { + func touchVisualizerWindowShouldAlwaysShowFingertip(_ window: COSTouchVisualizerWindow!) -> Bool { // Return YES to make the fingertip always display even if there's no any mirrored screen. // Return NO or don't implement this method if you want to keep the fingertip display only when // the device is connected to a mirrored screen. return true } - func touchVisualizerWindowShouldShowFingertip(window: COSTouchVisualizerWindow!) -> Bool { + func touchVisualizerWindowShouldShowFingertip(_ window: COSTouchVisualizerWindow!) -> Bool { // Return YES or don't implement this method to make this window show fingertip when necessary. // Return NO to make this window not to show fingertip. return true diff --git a/ExampleSwift/TouchVisualizer/Info.plist b/ExampleSwift/TouchVisualizer/Info.plist index 19db539..e214702 100644 --- a/ExampleSwift/TouchVisualizer/Info.plist +++ b/ExampleSwift/TouchVisualizer/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.conopsys.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/ExampleSwift/TouchVisualizer/MasterViewController.swift b/ExampleSwift/TouchVisualizer/MasterViewController.swift index 5ebe10a..a54c28a 100644 --- a/ExampleSwift/TouchVisualizer/MasterViewController.swift +++ b/ExampleSwift/TouchVisualizer/MasterViewController.swift @@ -20,9 +20,9 @@ class MasterViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. - self.navigationItem.leftBarButtonItem = self.editButtonItem() + self.navigationItem.leftBarButtonItem = self.editButtonItem - let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "insertNewObject:") + let addButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(MasterViewController.insertNewObject(_:))) self.navigationItem.rightBarButtonItem = addButton } @@ -31,51 +31,51 @@ class MasterViewController: UITableViewController { // Dispose of any resources that can be recreated. } - func insertNewObject(sender: AnyObject) { - objects.insert(NSDate(), atIndex: 0) - let indexPath = NSIndexPath(forRow: 0, inSection: 0) - self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) + func insertNewObject(_ sender: AnyObject) { + objects.insert(Date() as AnyObject, at: 0) + let indexPath = IndexPath(row: 0, section: 0) + self.tableView.insertRows(at: [indexPath], with: .automatic) } // MARK: - Segues - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "showDetail" { - if let indexPath = self.tableView.indexPathForSelectedRow() { + if let indexPath = self.tableView.indexPathForSelectedRow { let object = objects[indexPath.row] as! NSDate - (segue.destinationViewController as! DetailViewController).detailItem = object + (segue.destination as! DetailViewController).detailItem = object } } } // MARK: - Table View - override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + override func numberOfSections(in tableView: UITableView) -> Int { return 1 } - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return objects.count } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) - let object = objects[indexPath.row] as! NSDate + let object = objects[indexPath.row] as! Date cell.textLabel!.text = object.description return cell } - override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { // Return false if you do not want the specified item to be editable. return true } - override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { - if editingStyle == .Delete { - objects.removeAtIndex(indexPath.row) - tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) - } else if editingStyle == .Insert { + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + objects.remove(at: indexPath.row) + tableView.deleteRows(at: [indexPath], with: .fade) + } else if editingStyle == .insert { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. } } diff --git a/ExampleSwift/TouchVisualizerTests/Info.plist b/ExampleSwift/TouchVisualizerTests/Info.plist index 3b88946..ba72822 100644 --- a/ExampleSwift/TouchVisualizerTests/Info.plist +++ b/ExampleSwift/TouchVisualizerTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.conopsys.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/ExampleSwift/TouchVisualizerTests/TouchVisualizerTests.swift b/ExampleSwift/TouchVisualizerTests/TouchVisualizerTests.swift index b827796..9b1eb7f 100644 --- a/ExampleSwift/TouchVisualizerTests/TouchVisualizerTests.swift +++ b/ExampleSwift/TouchVisualizerTests/TouchVisualizerTests.swift @@ -28,7 +28,7 @@ class TouchVisualizerTests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock() { + self.measure() { // Put the code you want to measure the time of here. } }