From 54a76f5d0a803e1ace4cf37000fc0567bfb355bf Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 16 Dec 2015 19:24:43 +0900 Subject: [PATCH] WIP: spotlight demo app prototype --- .travis.yml | 8 +- CoreStore.xcodeproj/project.pbxproj | 10 +- .../CoreStoreDemo.xcodeproj/project.pbxproj | 12 +++ .../CoreStoreDemo/Base.lproj/Main.storyboard | 97 +++++++++++++++++-- .../SpotlightDemoViewController.swift | 69 +++++++++++++ 5 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 CoreStoreDemo/CoreStoreDemo/Spotlight Demo/SpotlightDemoViewController.swift diff --git a/.travis.yml b/.travis.yml index ad1dbef..98b4f53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,14 @@ git: submodules: false notifications: email: false +branches: + only: + - master + - develop env: global: - - LC_CTYPE=en_US.UTF-8 - - LANG=en_US.UTF-8 + - LC_CTYPE=en_US.UTF-8 + - LANG=en_US.UTF-8 matrix: - DESTINATION="OS=9.1,name=iPhone 6s" SCHEME="CoreStore iOS" SDK=iphonesimulator9.1 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=9.0,name=iPhone 6 Plus" SCHEME="CoreStore iOS" SDK=iphonesimulator9.1 RUN_TESTS="YES" POD_LINT="NO" diff --git a/CoreStore.xcodeproj/project.pbxproj b/CoreStore.xcodeproj/project.pbxproj index b424712..7eb4f8b 100644 --- a/CoreStore.xcodeproj/project.pbxproj +++ b/CoreStore.xcodeproj/project.pbxproj @@ -138,6 +138,8 @@ B56965241B356B820075EE4A /* MigrationResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56965231B356B820075EE4A /* MigrationResult.swift */; }; B59D5C221B5BA34B00453479 /* NSFileManager+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59D5C211B5BA34B00453479 /* NSFileManager+Setup.swift */; }; B5A261211B64BFDB006EB6D3 /* MigrationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A261201B64BFDB006EB6D3 /* MigrationType.swift */; }; + B5A93A111C212CB800E47273 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5A93A101C212CB800E47273 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + B5A93A161C21679A00E47273 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5A93A151C21679A00E47273 /* MobileCoreServices.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; B5BDC91D1C2023CF008147CD /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC91C1C2023CF008147CD /* GCDKit.framework */; }; B5BDC91E1C2023E8008147CD /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC91C1C2023CF008147CD /* GCDKit.framework */; }; B5D1E22C19FA9FBC003B2874 /* NSError+CoreStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D1E22B19FA9FBC003B2874 /* NSError+CoreStore.swift */; }; @@ -235,6 +237,8 @@ B56965231B356B820075EE4A /* MigrationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MigrationResult.swift; sourceTree = ""; }; B59D5C211B5BA34B00453479 /* NSFileManager+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFileManager+Setup.swift"; sourceTree = ""; }; B5A261201B64BFDB006EB6D3 /* MigrationType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MigrationType.swift; sourceTree = ""; }; + B5A93A101C212CB800E47273 /* CoreSpotlight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreSpotlight.framework; path = System/Library/Frameworks/CoreSpotlight.framework; sourceTree = SDKROOT; }; + B5A93A151C21679A00E47273 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; B5BDC91A1C202269008147CD /* CartFile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CartFile; sourceTree = ""; }; B5BDC91C1C2023CF008147CD /* GCDKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GCDKit.framework; path = "../../../Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/GCDKit.framework"; sourceTree = ""; }; B5BDC9271C2024F2008147CD /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = SOURCE_ROOT; }; @@ -297,9 +301,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B5BDC91D1C2023CF008147CD /* GCDKit.framework in Frameworks */, + B5A93A111C212CB800E47273 /* CoreSpotlight.framework in Frameworks */, + B5A93A161C21679A00E47273 /* MobileCoreServices.framework in Frameworks */, B5D39A0219FD00C9000E91BB /* Foundation.framework in Frameworks */, 2F03A54D19C5C872005002A5 /* CoreData.framework in Frameworks */, + B5BDC91D1C2023CF008147CD /* GCDKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -418,6 +424,8 @@ 2F291E3119C6D4D3007AF63F /* Frameworks */ = { isa = PBXGroup; children = ( + B5A93A151C21679A00E47273 /* MobileCoreServices.framework */, + B5A93A101C212CB800E47273 /* CoreSpotlight.framework */, B5BDC91C1C2023CF008147CD /* GCDKit.framework */, B5548CD71BD65AE50077652A /* CoreData.framework */, B56321791BD650DE006C9394 /* CoreData.framework */, diff --git a/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj b/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj index 1354f03..efa78ea 100644 --- a/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj +++ b/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ B569651A1B30888A0075EE4A /* FetchingResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56965191B30888A0075EE4A /* FetchingResultsViewController.swift */; }; B569651C1B30889A0075EE4A /* QueryingResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B569651B1B30889A0075EE4A /* QueryingResultsViewController.swift */; }; B56965291B3582D30075EE4A /* MigrationDemo.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = B56965271B3582D30075EE4A /* MigrationDemo.xcdatamodeld */; }; + B5A93A141C214E5900E47273 /* SpotlightDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A93A131C214E5900E47273 /* SpotlightDemoViewController.swift */; }; B5BDC9221C202429008147CD /* CoreStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9211C202429008147CD /* CoreStore.framework */; }; B5BDC9231C202429008147CD /* CoreStore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9211C202429008147CD /* CoreStore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; B5BDC9251C202429008147CD /* GCDKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BDC9241C202429008147CD /* GCDKit.framework */; }; @@ -93,6 +94,7 @@ B56965191B30888A0075EE4A /* FetchingResultsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchingResultsViewController.swift; sourceTree = ""; }; B569651B1B30889A0075EE4A /* QueryingResultsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryingResultsViewController.swift; sourceTree = ""; }; B56965281B3582D30075EE4A /* MigrationDemo.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MigrationDemo.xcdatamodel; sourceTree = ""; }; + B5A93A131C214E5900E47273 /* SpotlightDemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotlightDemoViewController.swift; sourceTree = ""; }; B5BDC9211C202429008147CD /* CoreStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = CoreStore.framework; path = "/Users/JohnEstropia/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/CoreStore.framework"; sourceTree = ""; }; B5BDC9241C202429008147CD /* GCDKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = GCDKit.framework; path = "/Users/JohnEstropia/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/GCDKit.framework"; sourceTree = ""; }; B5E599311B5240F50084BD5F /* OrganismTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OrganismTableViewCell.swift; path = "CoreStoreDemo/MIgrations Demo/OrganismTableViewCell.swift"; sourceTree = SOURCE_ROOT; }; @@ -173,6 +175,7 @@ isa = PBXGroup; children = ( B54AAD4E1AF4D26E00848AE0 /* AppDelegate.swift */, + B5A93A121C214D9D00E47273 /* Spotlight Demo */, B566E3271B117AE700F4F0C6 /* Stack Setup Demo */, B503FADA1AFDC71700F90881 /* List and Object Observers Demo */, B52977DB1B120F2C003D50A5 /* Transactions Demo */, @@ -244,6 +247,14 @@ path = "Migrations Demo"; sourceTree = ""; }; + B5A93A121C214D9D00E47273 /* Spotlight Demo */ = { + isa = PBXGroup; + children = ( + B5A93A131C214E5900E47273 /* SpotlightDemoViewController.swift */, + ); + path = "Spotlight Demo"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -342,6 +353,7 @@ B56964D71B231AE90075EE4A /* StackSetupDemo.xcdatamodeld in Sources */, B56964DC1B231BCB0075EE4A /* FemaleAccount.swift in Sources */, B5EE259E1B3EC1B20000406B /* OrganismProtocol.swift in Sources */, + B5A93A141C214E5900E47273 /* SpotlightDemoViewController.swift in Sources */, B5EE258C1B36E40D0000406B /* MigrationsDemoViewController.swift in Sources */, B569651C1B30889A0075EE4A /* QueryingResultsViewController.swift in Sources */, B5125C121B521B78003A42C7 /* OrganismV2ToV3.xcmappingmodel in Sources */, diff --git a/CoreStoreDemo/CoreStoreDemo/Base.lproj/Main.storyboard b/CoreStoreDemo/CoreStoreDemo/Base.lproj/Main.storyboard index 1a2c4ed..6cb86eb 100644 --- a/CoreStoreDemo/CoreStoreDemo/Base.lproj/Main.storyboard +++ b/CoreStoreDemo/CoreStoreDemo/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -33,6 +33,7 @@ HelveticaNeue-Light HelveticaNeue-Light HelveticaNeue-Light + HelveticaNeue-Light @@ -297,7 +298,7 @@ - + diff --git a/CoreStoreDemo/CoreStoreDemo/Spotlight Demo/SpotlightDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Spotlight Demo/SpotlightDemoViewController.swift new file mode 100644 index 0000000..f612b78 --- /dev/null +++ b/CoreStoreDemo/CoreStoreDemo/Spotlight Demo/SpotlightDemoViewController.swift @@ -0,0 +1,69 @@ +// +// SpotlightDemoViewController.swift +// CoreStoreDemo +// +// Created by John Estropia on 2015/12/16. +// Copyright © 2015年 John Rommel Estropia. All rights reserved. +// + +import UIKit +import CoreSpotlight + + +// MARK: - SpotlightDemoViewController + +class SpotlightDemoViewController: UITableViewController { + + private var dataSource = [(String, String)]() + + // MARK: UITableViewDataSource + + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + + return 1 + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + return self.dataSource.count + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + + let cell = tableView.dequeueReusableCellWithIdentifier("SpotlightItemCell")! + let item = self.dataSource[indexPath.row] + cell.textLabel?.text = item.0 + cell.detailTextLabel?.text = item.1 + return cell + } + + // MARK: UITableViewDelegate + + override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { + + if case .Delete = editingStyle { + + tableView.beginUpdates() + tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) + self.dataSource.removeAtIndex(indexPath.row) + tableView.endUpdates() + } + } + + // MARK: Private + + @IBAction private dynamic func addBarButtonTapped(sender: UIBarButtonItem) { + + let items = [("John", "iOS team"), ("Bob", "Android team"), ("Joe", "Infra team"), ("Ryan", "Director"), ("Jake", "Design team"), ("Mark", "Testing team")] + guard let nextItem = items.filter({ !self.dataSource.map({ $0.0 }).contains($0.0) }).first else { + + return + } + + let tableView = self.tableView + tableView.beginUpdates() + tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: self.dataSource.count, inSection: 0)], withRowAnimation: .Automatic) + self.dataSource.append(nextItem) + tableView.endUpdates() + } +}