Skip to content

Commit

Permalink
Merge pull request #18 from yichizhang/dev
Browse files Browse the repository at this point in the history
Swift 3.2.2
  • Loading branch information
yichizhang authored Nov 5, 2017
2 parents c41254c + 0420fb3 commit 237d426
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 76 deletions.
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v7.0.0"
github "Quick/Quick" "v1.1.0"
github "Quick/Nimble" "v7.0.2"
github "Quick/Quick" "v1.2.0"
4 changes: 2 additions & 2 deletions Source/StringScore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public extension String
finalScore = 0.0,
string = self,
lString = string.lowercased(),
strLength = string.characters.count,
strLength = string.count,
lWord = word.lowercased(),
wordLength = word.characters.count,
wordLength = word.count,
idxOf: String.Index!,
startAt = lString.startIndex,
fuzzies = 1.0,
Expand Down
39 changes: 5 additions & 34 deletions StringScoreDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,12 @@

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

return true
}

func applicationWillResignActive(_ application: UIApplication)
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication)
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication)
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication)
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
64 changes: 33 additions & 31 deletions StringScoreDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="0Mi-v7-gIa">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="0Mi-v7-gIa">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Item-->
<scene sceneID="KUP-ex-XQT">
<objects>
<navigationController id="ENb-jv-egC" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="CUU-w8-ksC"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="xYk-7P-P4l">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="xYk-7P-P4l">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -32,60 +35,60 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Vru-5G-9dj">
<rect key="frame" x="20" y="57" width="560" height="30"/>
<rect key="frame" x="16" y="57" width="343" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="S1T-PB-fhf">
<rect key="frame" x="20" y="123" width="560" height="100"/>
<rect key="frame" x="16" y="123" width="343" height="100"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="zQn-fa-DPX"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Find:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="n3j-7d-yWQ">
<rect key="frame" x="20" y="28" width="38" height="21"/>
<rect key="frame" x="16" y="28" width="38" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="In:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7lM-Fz-3pL">
<rect key="frame" x="20" y="95" width="19" height="20"/>
<rect key="frame" x="16" y="95" width="19" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="SA5-xp-PHM">
<rect key="frame" x="107" y="234" width="475" height="31"/>
<rect key="frame" x="103" y="234" width="258" height="31"/>
</slider>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Fuzziness:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="btH-Zf-wXE">
<rect key="frame" x="20" y="238" width="81" height="21"/>
<rect key="frame" x="16" y="238" width="81" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.000" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GfV-si-tom">
<rect key="frame" x="490" y="26.5" width="90" height="24"/>
<rect key="frame" x="269" y="26.5" width="90" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="OiX-bi-2Q4"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="20"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Result:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Ne-eX-eyV">
<rect key="frame" x="429.5" y="28" width="52.5" height="20.5"/>
<rect key="frame" x="208.5" y="28" width="52.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="SA5-xp-PHM" firstAttribute="centerY" secondItem="0Ne-eX-eyV" secondAttribute="centerY" id="0lN-Hr-LdS"/>
<constraint firstItem="n3j-7d-yWQ" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="1hC-UE-82p"/>
Expand Down Expand Up @@ -153,8 +156,7 @@
<objects>
<navigationController id="bqW-xd-kww" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="BHG-US-mP3"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="p1t-2D-xXl">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="p1t-2D-xXl">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -173,7 +175,7 @@
<tabBar key="tabBar" contentMode="scaleToFill" id="h9m-iQ-UcP">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</tabBar>
<connections>
<segue destination="bqW-xd-kww" kind="relationship" relationship="viewControllers" id="eUf-s2-A1w"/>
Expand All @@ -189,29 +191,29 @@
<objects>
<tableViewController id="yLf-gR-ycW" customClass="DemoSearchTableController" customModule="StringScoreDemo" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="j6a-iN-cgP">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="CellId" textLabel="VDy-lo-Uo1" detailTextLabel="BaO-Bm-sVY" style="IBUITableViewCellStyleValue1" id="Jnm-Fd-Rub">
<rect key="frame" x="0.0" y="86" width="600" height="44"/>
<rect key="frame" x="0.0" y="22" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Jnm-Fd-Rub" id="FaR-qB-zVF">
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="VDy-lo-Uo1">
<rect key="frame" x="15" y="12" width="31.5" height="19.5"/>
<rect key="frame" x="16" y="12" width="31.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="BaO-Bm-sVY">
<rect key="frame" x="543.5" y="12" width="41.5" height="19.5"/>
<rect key="frame" x="317.5" y="12" width="41.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down
2 changes: 1 addition & 1 deletion StringScoreDemo/CustomInputViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CustomInputViewController: UIViewController, UITextViewDelegate
func updateStringScore()
{
if let sourceText = sourceTextView.text, let searchText = searchTextField.text {
let score = sourceText.score(searchText, fuzziness: Double(fuzzinessSlider.value))
let score = sourceText.score(word: searchText, fuzziness: Double(fuzzinessSlider.value))
resultLabel.text = score.yz_toString()
}
}
Expand Down
Loading

0 comments on commit 237d426

Please sign in to comment.