Skip to content

Commit

Permalink
Migrate to Swift 3
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Feb 16, 2017
2 parents 713e33d + 0d90e42 commit 88affb5
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 86 deletions.
2 changes: 1 addition & 1 deletion ParkedTextField.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ParkedTextField"
s.version = "0.2.1"
s.version = "0.3.0"
s.summary = "A UITextField subclass with an appended constant text"
s.homepage = "https://github.com/gmertk/ParkedTextField"
s.screenshots = "https://dl.dropboxusercontent.com/u/4397140/pod-screenshots/ParkedTextField.gif"
Expand Down
12 changes: 6 additions & 6 deletions ParkedTextField/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
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) {
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) {
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) {
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) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
53 changes: 26 additions & 27 deletions ParkedTextField/Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?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="N8b-2N-8cb">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="N8b-2N-8cb">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -14,39 +19,36 @@
<viewControllerLayoutGuide type="bottom" id="684-VQ-35L"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="AuB-Wi-3kB">
<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" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="rFj-QV-Tqa" customClass="ParkedTextField" customModule="ParkedTextField">
<rect key="frame" x="16" y="80" width="568" height="33"/>
<animations/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<rect key="frame" x="16" y="80" width="343" height="33"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="24"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
<connections>
<action selector="valueChanged:" destination="N8b-2N-8cb" eventType="editingChanged" id="BXm-gv-e8o"/>
<action selector="valueChangedWithSender:" destination="N8b-2N-8cb" eventType="editingDidEnd" id="IQU-qJ-Mfb"/>
</connections>
</textField>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="J5o-E9-1aO">
<rect key="frame" x="0.0" y="163" width="600" height="150"/>
<rect key="frame" x="0.0" y="163" width="375" height="150"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="center" adjustsFontSizeToFit="NO" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="agk-D2-4Ls" customClass="ParkedTextField" customModule="ParkedTextField">
<rect key="frame" x="16" y="58" width="568" height="33"/>
<animations/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<rect key="frame" x="16" y="58" width="343" height="33"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="24"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="parkedText" value="@gmail.com"/>
<userDefinedRuntimeAttribute type="string" keyPath="placeholderText" value="username"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="valueChanged:" destination="N8b-2N-8cb" eventType="editingChanged" id="gh0-Aa-zEY"/>
<action selector="valueChangedWithSender:" destination="N8b-2N-8cb" eventType="editingDidEnd" id="dWF-Dl-hHy"/>
</connections>
</textField>
</subviews>
<animations/>
<color key="backgroundColor" red="1" green="0.35686274509999999" blue="0.36470588240000001" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="1" green="0.35686274509999999" blue="0.36470588240000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="agk-D2-4Ls" firstAttribute="leading" secondItem="J5o-E9-1aO" secondAttribute="leading" constant="16" id="O0c-Is-WtC"/>
<constraint firstAttribute="height" constant="150" id="QRW-1E-CN0"/>
Expand All @@ -55,32 +57,29 @@
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IRc-H2-dzV">
<rect key="frame" x="236.5" y="337" width="127" height="40"/>
<animations/>
<rect key="frame" x="124" y="337" width="127" height="40"/>
<fontDescription key="fontDescription" name="AvenirNext-DemiBold" family="Avenir Next" pointSize="20"/>
<state key="normal" title="Set typedText">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="changeNotParkedText:" destination="N8b-2N-8cb" eventType="touchUpInside" id="YoE-Ab-gzv"/>
<action selector="changeNotParkedTextWithSender:" destination="N8b-2N-8cb" eventType="touchUpInside" id="mEU-69-PVc"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cwm-eU-feP">
<rect key="frame" x="230.5" y="380" width="139" height="40"/>
<animations/>
<rect key="frame" x="118" y="380" width="139" height="40"/>
<fontDescription key="fontDescription" name="AvenirNext-DemiBold" family="Avenir Next" pointSize="20"/>
<state key="normal" title="Set parkedText">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="changeParkedText:" destination="N8b-2N-8cb" eventType="touchUpInside" id="7pt-nv-YMb"/>
<action selector="changeParkedTextWithSender:" destination="N8b-2N-8cb" eventType="touchUpInside" id="UlM-Ul-rYc"/>
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" red="0.38740914129999998" green="0.28280879939999998" blue="0.5780976122" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.38740914129999998" green="0.28280879939999998" blue="0.5780976122" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="IRc-H2-dzV" firstAttribute="leading" secondItem="cwm-eU-feP" secondAttribute="trailing" constant="35" id="3lV-Kz-fc8"/>
<constraint firstAttribute="trailing" secondItem="J5o-E9-1aO" secondAttribute="trailing" id="7M5-Pp-lXl"/>
Expand Down
14 changes: 7 additions & 7 deletions ParkedTextField/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ class ViewController: UIViewController {
print("typedText = " + sender.typedText)
}

@IBAction func changeNotParkedText(sender: AnyObject) {
let texts = ["ios-developers", "larry", "bill", "mark"]
gmailTextField.typedText = texts[i]

i = (i + 1) % texts.count
}

@IBAction func changeParkedText(sender: AnyObject) {
let texts = [".slack.com", "@gmail.com", "@hotmail.com", "@facebook.com"]
gmailTextField.parkedText = texts[j]

j = (j + 1) % texts.count
}


@IBAction func changeNotParkedText(sender: AnyObject) {
let texts = ["ios-developers", "larry", "bill", "mark"]
gmailTextField.typedText = texts[i]

i = (i + 1) % texts.count
}
}
10 changes: 0 additions & 10 deletions ParkedTextField/ExampleTests/ExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,14 @@ class ExampleTests: XCTestCase {

override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}

}
Loading

0 comments on commit 88affb5

Please sign in to comment.