Skip to content

Commit

Permalink
Converted to Swift 2
Browse files Browse the repository at this point in the history
- Used Xcode's built-in tool to convert to `Swift 2.0`
- Reorganized the project with `synx` (will be helpful when we add `Add Groups` to it
  • Loading branch information
esttorhe committed Aug 18, 2015
1 parent e55d766 commit 8f8f907
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 59 deletions.
17 changes: 8 additions & 9 deletions NaughtyKeyboard/KeyboardViewController.swift
Expand Up @@ -11,14 +11,14 @@ import UIKit
class KeyboardViewController: UIInputViewController {

let tableView = UITableView(frame: CGRectZero, style: .Plain)
let nextKeyboardButton = UIButton.buttonWithType(.Custom) as! UIButton
let nextKeyboardButton = UIButton(type: .Custom)

var strings: [String] = []

override func viewDidLoad() {
super.viewDidLoad()

nextKeyboardButton.setTranslatesAutoresizingMaskIntoConstraints(false)
nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = false
nextKeyboardButton.setTitle("Switch keyboard", forState: .Normal)
nextKeyboardButton.addTarget(self, action: Selector("didTapNextKeyboardButton"), forControlEvents: .TouchUpInside)
view.addSubview(nextKeyboardButton)
Expand All @@ -28,7 +28,7 @@ class KeyboardViewController: UIInputViewController {
view.addConstraints([ leftButtonConstraint, topButtonConstraint])

tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "StringCell")
tableView.setTranslatesAutoresizingMaskIntoConstraints(false)
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.delegate = self
tableView.dataSource = self
view.addSubview(tableView)
Expand All @@ -39,8 +39,9 @@ class KeyboardViewController: UIInputViewController {
let rightConstraint = NSLayoutConstraint(item: tableView, attribute: .Right, relatedBy: .Equal, toItem: view, attribute: .Right, multiplier: 1.0, constant: 0)
view.addConstraints([topConstraint, leftConstraint, bottomConstraint, rightConstraint])

// TODO: Load from the shared container
let path = NSBundle(forClass: self.dynamicType).pathForResource("blns", ofType: "json")!
strings = NSJSONSerialization.JSONObjectWithData(NSData(contentsOfFile: path)!, options: NSJSONReadingOptions.allZeros, error: nil) as! [String]
strings = try! NSJSONSerialization.JSONObjectWithData(NSData(contentsOfFile: path)!, options: NSJSONReadingOptions()) as! [String]
tableView.reloadData()
}

Expand All @@ -52,15 +53,13 @@ class KeyboardViewController: UIInputViewController {
extension KeyboardViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let string = strings[indexPath.row]
if let proxy = textDocumentProxy as? UIKeyInput {
proxy.insertText(string)
proxy.insertText("\n")
}
textDocumentProxy.insertText(string)
textDocumentProxy.insertText("\n")
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("StringCell", forIndexPath: indexPath) as! UITableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier("StringCell", forIndexPath: indexPath)
cell.textLabel?.text = strings[indexPath.row]

return cell
Expand Down
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.perfectly-cooked.NaughtyStrings.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
61 changes: 44 additions & 17 deletions NaughtyStrings.xcodeproj/project.pbxproj
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
1111E6031B83DB810056A8F8 /* explaination.html in Resources */ = {isa = PBXBuildFile; fileRef = 1111E6021B83DB810056A8F8 /* explaination.html */; };
7A3E7AFC1B796BF40084CBF6 /* blns.json in Resources */ = {isa = PBXBuildFile; fileRef = 7A3E7AFB1B796BF40084CBF6 /* blns.json */; };
7A3E7B061B7A65C30084CBF6 /* explaination.html in Resources */ = {isa = PBXBuildFile; fileRef = 7A3E7B051B7A65C20084CBF6 /* explaination.html */; };
7A806BE41B79111F00D18F88 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A806BE31B79111F00D18F88 /* AppDelegate.swift */; };
7A806BE61B79111F00D18F88 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A806BE51B79111F00D18F88 /* ViewController.swift */; };
7A806BE91B79111F00D18F88 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A806BE71B79111F00D18F88 /* Main.storyboard */; };
Expand Down Expand Up @@ -51,8 +51,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
1111E6021B83DB810056A8F8 /* explaination.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = explaination.html; sourceTree = "<group>"; };
7A3E7AFB1B796BF40084CBF6 /* blns.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = blns.json; sourceTree = "<group>"; };
7A3E7B051B7A65C20084CBF6 /* explaination.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = explaination.html; sourceTree = "<group>"; };
7A806BDE1B79111F00D18F88 /* NaughtyStrings.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NaughtyStrings.app; sourceTree = BUILT_PRODUCTS_DIR; };
7A806BE21B79111F00D18F88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7A806BE31B79111F00D18F88 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -93,6 +93,23 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
1111E5FB1B83D6C50056A8F8 /* UI */ = {
isa = PBXGroup;
children = (
7A806BE71B79111F00D18F88 /* Main.storyboard */,
7A806BEC1B79111F00D18F88 /* LaunchScreen.xib */,
);
path = UI;
sourceTree = "<group>";
};
1111E5FC1B83D6CB0056A8F8 /* ViewControllers */ = {
isa = PBXGroup;
children = (
7A806BE51B79111F00D18F88 /* ViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
};
7A806BD51B79111F00D18F88 = {
isa = PBXGroup;
children = (
Expand All @@ -117,22 +134,21 @@
isa = PBXGroup;
children = (
7A806BE31B79111F00D18F88 /* AppDelegate.swift */,
7A806BE51B79111F00D18F88 /* ViewController.swift */,
7A806BE71B79111F00D18F88 /* Main.storyboard */,
1111E5FC1B83D6CB0056A8F8 /* ViewControllers */,
1111E5FB1B83D6C50056A8F8 /* UI */,
7A806BEA1B79111F00D18F88 /* Images.xcassets */,
7A806BEC1B79111F00D18F88 /* LaunchScreen.xib */,
7A806BE11B79111F00D18F88 /* Supporting Files */,
7A3E7B051B7A65C20084CBF6 /* explaination.html */,
);
path = NaughtyStrings;
sourceTree = "<group>";
};
7A806BE11B79111F00D18F88 /* Supporting Files */ = {
isa = PBXGroup;
children = (
1111E6021B83DB810056A8F8 /* explaination.html */,
7A806BE21B79111F00D18F88 /* Info.plist */,
);
name = "Supporting Files";
path = "Supporting Files";
sourceTree = "<group>";
};
7A806BF61B79111F00D18F88 /* NaughtyStringsTests */ = {
Expand All @@ -149,7 +165,7 @@
children = (
7A806BF81B79111F00D18F88 /* Info.plist */,
);
name = "Supporting Files";
path = "Supporting Files";
sourceTree = "<group>";
};
7A806C081B7912B400D18F88 /* NaughtyKeyboard */ = {
Expand All @@ -167,7 +183,7 @@
children = (
7A806C0A1B7912B400D18F88 /* Info.plist */,
);
name = "Supporting Files";
path = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -233,7 +249,9 @@
7A806BD61B79111F00D18F88 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0640;
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Perfectly-Cooked";
TargetAttributes = {
7A806BDD1B79111F00D18F88 = {
Expand Down Expand Up @@ -273,8 +291,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1111E6031B83DB810056A8F8 /* explaination.html in Resources */,
7A806BE91B79111F00D18F88 /* Main.storyboard in Resources */,
7A3E7B061B7A65C30084CBF6 /* explaination.html in Resources */,
7A806BEE1B79111F00D18F88 /* LaunchScreen.xib in Resources */,
7A806BEB1B79111F00D18F88 /* Images.xcassets in Resources */,
);
Expand Down Expand Up @@ -345,6 +363,7 @@
7A806BE81B79111F00D18F88 /* Base */,
);
name = Main.storyboard;
path = .;
sourceTree = "<group>";
};
7A806BEC1B79111F00D18F88 /* LaunchScreen.xib */ = {
Expand All @@ -353,6 +372,7 @@
7A806BED1B79111F00D18F88 /* Base */,
);
name = LaunchScreen.xib;
path = .;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
Expand All @@ -379,6 +399,7 @@
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;
Expand Down Expand Up @@ -443,8 +464,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = NaughtyStrings/Info.plist;
INFOPLIST_FILE = "NaughtyStrings/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.perfectly-cooked.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -453,8 +475,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = NaughtyStrings/Info.plist;
INFOPLIST_FILE = "NaughtyStrings/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.perfectly-cooked.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand All @@ -471,8 +494,9 @@
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = NaughtyStringsTests/Info.plist;
INFOPLIST_FILE = "NaughtyStringsTests/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.perfectly-cooked.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NaughtyStrings.app/NaughtyStrings";
};
Expand All @@ -486,8 +510,9 @@
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = NaughtyStringsTests/Info.plist;
INFOPLIST_FILE = "NaughtyStringsTests/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.perfectly-cooked.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NaughtyStrings.app/NaughtyStrings";
};
Expand All @@ -500,8 +525,9 @@
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = NaughtyKeyboard/Info.plist;
INFOPLIST_FILE = "NaughtyKeyboard/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.perfectly-cooked.NaughtyStrings.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
Expand All @@ -510,8 +536,9 @@
7A806C121B7912B500D18F88 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = NaughtyKeyboard/Info.plist;
INFOPLIST_FILE = "NaughtyKeyboard/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.perfectly-cooked.NaughtyStrings.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
Expand Down
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.perfectly-cooked.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand All @@ -20,6 +20,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8173.3" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8142"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
Expand All @@ -18,31 +19,49 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Install instructions" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ktf-ly-BfV">
<rect key="frame" x="232" y="28" width="136" height="20"/>
<rect key="frame" x="230" y="28" width="140" height="19.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pZd-nB-DNV">
<rect key="frame" x="36" y="68" width="528" height="512"/>
<rect key="frame" x="40" y="67" width="520" height="512.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NOs-Xl-pUd">
<rect key="frame" x="225" y="477" width="149" height="30"/>
<state key="normal" title="Sync Naughty Strings"/>
<connections>
<action selector="sync_touched:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="67j-Dj-JyX"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Last updated: Never" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4HH-dL-m2a">
<rect key="frame" x="246" y="508" width="106.5" height="13.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="pZd-nB-DNV" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="20" id="23t-l5-c3C"/>
<constraint firstItem="4HH-dL-m2a" firstAttribute="top" secondItem="pZd-nB-DNV" secondAttribute="bottom" constant="-71.5" id="Cny-e6-nLb"/>
<constraint firstItem="4HH-dL-m2a" firstAttribute="top" secondItem="NOs-Xl-pUd" secondAttribute="bottom" constant="1" id="Gkp-oT-v7i"/>
<constraint firstAttribute="trailingMargin" secondItem="pZd-nB-DNV" secondAttribute="trailing" constant="20" id="H8f-Rc-UIR"/>
<constraint firstItem="ktf-ly-BfV" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="8" id="NAw-lY-NKg"/>
<constraint firstAttribute="centerX" secondItem="ktf-ly-BfV" secondAttribute="centerX" id="PKZ-nZ-rMY"/>
<constraint firstItem="pZd-nB-DNV" firstAttribute="top" secondItem="ktf-ly-BfV" secondAttribute="bottom" constant="20" id="WJ5-qR-kG2"/>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="pZd-nB-DNV" secondAttribute="bottom" constant="20" id="eiL-um-u2E"/>
<constraint firstItem="4HH-dL-m2a" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="k1Y-Kf-gzf"/>
<constraint firstItem="NOs-Xl-pUd" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="sRC-NX-ZiB"/>
</constraints>
</view>
<connections>
<outlet property="descriptionContainer" destination="pZd-nB-DNV" id="yRp-eJ-ii9"/>
<outlet property="lastSyncedLabel" destination="4HH-dL-m2a" id="8A2-f9-ifa"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
Expand Down

0 comments on commit 8f8f907

Please sign in to comment.