Commit af78de10 authored by Aral Balkan's avatar Aral Balkan

Update for Xcode 8 GM

* Clean up code
* Update dependencies
* Update OS X → macOS naming
parent 3ffc762d
git "git@source.ind.ie:project/handle.git" "swift-3"
\ No newline at end of file
git "git@source.ind.ie:project/handle.git"
\ No newline at end of file
git "git@source.ind.ie:project/handle.git" "dd2e541ca6dbc97b91546155be411ed46f0a4182"
git "git@source.ind.ie:project/handle.git" "4.0.0"
......@@ -5,7 +5,7 @@
location = "group:DelayDemo-iOS/DelayDemo-iOS.xcodeproj">
</FileRef>
<FileRef
location = "group:DelayDemo-OSX/DelayDemo-OSX.xcodeproj">
location = "group:/Users/aral/Ind.ie/products/Delay/DelayDemo-OSX/DelayDemo-macOS.xcodeproj">
</FileRef>
<FileRef
location = "group:Delay/Delay.xcodeproj">
......
......@@ -39,7 +39,7 @@ import Foundation
// Swift 3 (to replace dispatch_block_t)
public typealias Block = (Void) -> Void
public func delay(_ delay:Double, block:Block) -> CancellableDelayedCommand
public func delay(_ delay:Double, block:@escaping Block) -> CancellableDelayedCommand
{
return CancellableDelayedCommand(delay: delay, block: block)
}
......@@ -55,7 +55,7 @@ open class CancellableDelayedCommand
var cancelled:Bool
var delay:Double
public init(delay:Double, block:Block)
public init(delay:Double, block:@escaping Block)
{
self.delay = delay
self.originalBlock = block
......
......@@ -9,18 +9,16 @@
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
class AppDelegate: NSObject, NSApplicationDelegate
{
func applicationDidFinishLaunching(_ aNotification: Notification)
{
// Insert code here to initialize your application
}
func applicationWillTerminate(_ aNotification: Notification) {
func applicationWillTerminate(_ aNotification: Notification)
{
// Insert code here to tear down your application
}
}
////////////////////////////////////////////////////////////////////////////////
//
// Delay - demonstration - OS X.
// Delay - demonstration - macOS.
//
// With thanks to Mattt Thompson’s write-up on NSLinguisticTagger
// (http://nshipster.com/nslinguistictagger/)
......@@ -16,7 +16,7 @@ import Handle
// MARK: - Class
class OSXViewController: NSViewController
class MacOSViewController: NSViewController
{
// MARK: - Outlets
......@@ -47,33 +47,33 @@ class OSXViewController: NSViewController
override func viewWillAppear()
{
textDidChangeNotificationHandler = handle(NSNotification.Name.NSControlTextDidChange.rawValue, from:throttledTextField)
{
/* with */ notification in
//
// Wait 0.3 seconds after the last keystroke to analyse the entered text and
// provide a linguistic breakdown of it.
//
self.cancellableTextFieldLookupCommand = self.cancellableTextFieldLookupCommand?.reset() ?? delay(0.3)
{
/* with */ notification in
let options: NSLinguisticTagger.Options = [.omitWhitespace, .omitPunctuation, .joinNames]
let schemes = NSLinguisticTagger.availableTagSchemes(forLanguage: "en")
let tagger = NSLinguisticTagger(tagSchemes: schemes, options: Int(options.rawValue))
let text = self.throttledTextField.stringValue
tagger.string = text
//
// Wait 0.3 seconds after the last keystroke to analyse the entered text and
// provide a linguistic breakdown of it.
//
self.cancellableTextFieldLookupCommand = self.cancellableTextFieldLookupCommand?.reset() ?? delay(0.3)
{
let options: NSLinguisticTagger.Options = [.omitWhitespace, .omitPunctuation, .joinNames]
let schemes = NSLinguisticTagger.availableTagSchemes(forLanguage: "en")
let tagger = NSLinguisticTagger(tagSchemes: schemes, options: Int(options.rawValue))
let text = self.throttledTextField.stringValue
tagger.string = text
var linguisticBreakdownOfText = ""
tagger.enumerateTags(in: NSMakeRange(0, (text as NSString).length), scheme: NSLinguisticTagSchemeNameTypeOrLexicalClass, options: options)
{
(tag, tokenRange, sentenceRange, _) in
let token = (text as NSString).substring(with: tokenRange)
linguisticBreakdownOfText += "\(token): \(tag)\n"
}
self.throttledTextView.string = linguisticBreakdownOfText
var linguisticBreakdownOfText = ""
tagger.enumerateTags(in: NSMakeRange(0, (text as NSString).length), scheme: NSLinguisticTagSchemeNameTypeOrLexicalClass, options: options)
{
(tag, tokenRange, sentenceRange, _) in
let token = (text as NSString).substring(with: tokenRange)
linguisticBreakdownOfText += "\(token): \(tag)\n"
}
self.throttledTextView.string = linguisticBreakdownOfText
}
}
}
......
......@@ -35,7 +35,7 @@
/* Begin PBXFileReference section */
A7394BDC1CA435C70096FF28 /* Delay.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Delay.framework; path = "$(CONFIGURATION_BUILD_DIR)/Delay.framework"; sourceTree = "<group>"; };
A787D4671C24811E00CDBF66 /* Handle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Handle.framework; path = ../Carthage/Build/Mac/Handle.framework; sourceTree = "<group>"; };
A7C0EB6A1C2441C800110179 /* DelayDemo-OSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DelayDemo-OSX.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A7C0EB6A1C2441C800110179 /* DelayDemo-macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DelayDemo-macOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A7C0EB6D1C2441C800110179 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A7C0EB6F1C2441C800110179 /* OSXViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSXViewController.swift; sourceTree = "<group>"; };
A7C0EB711C2441C800110179 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -60,7 +60,7 @@
isa = PBXGroup;
children = (
A787D4671C24811E00CDBF66 /* Handle.framework */,
A7C0EB6C1C2441C800110179 /* DelayDemo-OSX */,
A7C0EB6C1C2441C800110179 /* DelayDemo-macOS */,
A7C0EB6B1C2441C800110179 /* Products */,
);
sourceTree = "<group>";
......@@ -68,12 +68,12 @@
A7C0EB6B1C2441C800110179 /* Products */ = {
isa = PBXGroup;
children = (
A7C0EB6A1C2441C800110179 /* DelayDemo-OSX.app */,
A7C0EB6A1C2441C800110179 /* DelayDemo-macOS.app */,
);
name = Products;
sourceTree = "<group>";
};
A7C0EB6C1C2441C800110179 /* DelayDemo-OSX */ = {
A7C0EB6C1C2441C800110179 /* DelayDemo-macOS */ = {
isa = PBXGroup;
children = (
A7C0EB6D1C2441C800110179 /* AppDelegate.swift */,
......@@ -82,15 +82,16 @@
A7C0EB731C2441C800110179 /* Main.storyboard */,
A7C0EB761C2441C800110179 /* Info.plist */,
);
name = "DelayDemo-macOS";
path = "DelayDemo-OSX";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
A7C0EB691C2441C800110179 /* DelayDemo-OSX */ = {
A7C0EB691C2441C800110179 /* DelayDemo-macOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = A7C0EB791C2441C800110179 /* Build configuration list for PBXNativeTarget "DelayDemo-OSX" */;
buildConfigurationList = A7C0EB791C2441C800110179 /* Build configuration list for PBXNativeTarget "DelayDemo-macOS" */;
buildPhases = (
A7C0EB661C2441C800110179 /* Sources */,
A7C0EB671C2441C800110179 /* Frameworks */,
......@@ -101,9 +102,9 @@
);
dependencies = (
);
name = "DelayDemo-OSX";
name = "DelayDemo-macOS";
productName = "DelayDemo-OSX";
productReference = A7C0EB6A1C2441C800110179 /* DelayDemo-OSX.app */;
productReference = A7C0EB6A1C2441C800110179 /* DelayDemo-macOS.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
......@@ -122,7 +123,7 @@
};
};
};
buildConfigurationList = A7C0EB651C2441C800110179 /* Build configuration list for PBXProject "DelayDemo-OSX" */;
buildConfigurationList = A7C0EB651C2441C800110179 /* Build configuration list for PBXProject "DelayDemo-macOS" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
......@@ -135,7 +136,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
A7C0EB691C2441C800110179 /* DelayDemo-OSX */,
A7C0EB691C2441C800110179 /* DelayDemo-macOS */,
);
};
/* End PBXProject section */
......@@ -301,7 +302,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
A7C0EB651C2441C800110179 /* Build configuration list for PBXProject "DelayDemo-OSX" */ = {
A7C0EB651C2441C800110179 /* Build configuration list for PBXProject "DelayDemo-macOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A7C0EB771C2441C800110179 /* Debug */,
......@@ -310,7 +311,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A7C0EB791C2441C800110179 /* Build configuration list for PBXNativeTarget "DelayDemo-OSX" */ = {
A7C0EB791C2441C800110179 /* Build configuration list for PBXNativeTarget "DelayDemo-macOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A7C0EB7A1C2441C800110179 /* Debug */,
......
......@@ -13,7 +13,7 @@ if hash carthage 2>/dev/null; then
echo "\nInstalling dependencies…\n"
# Install the dependencies for the demo apps.
carthage bootstrap
carthage bootstrap --platform iOS,Mac
# Done
printf "\n${successColour}Installation complete.${regularColour}\n\nTo start, type ./dev\n\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment