Skip to content

Commit

Permalink
[Update] Swift 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysee Monnier committed Sep 21, 2016
1 parent 2c11743 commit 06c2a30
Show file tree
Hide file tree
Showing 13 changed files with 1,255 additions and 606 deletions.
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- YMValidator (0.1.0)
- YMValidator (0.2.1)

DEPENDENCIES:
- YMValidator (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
YMValidator: 1a3ffd521b19e67241ad77eab9eac47472dcf9f7
YMValidator: a4cfd9f70f4d0cccf838f34348292b869f67e8c3

PODFILE CHECKSUM: 65da512345a55d270c38a6944a7b9ea649c0c531
PODFILE CHECKSUM: 33504f7340f9226e1935c5c3cda2eec11cf43ae2

COCOAPODS: 1.0.1
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/YMValidator.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,711 changes: 1,175 additions & 536 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Example/Pods/Target Support Files/YMValidator/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Example/YMValidator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = B6C6ND5V82;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -323,7 +325,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -361,7 +363,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand All @@ -373,11 +375,13 @@
baseConfigurationReference = D0D7FDCFAAFACC13731F8C31 /* Pods-YMValidator_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = B6C6ND5V82;
INFOPLIST_FILE = YMValidator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -386,11 +390,13 @@
baseConfigurationReference = A59F33763F9E1C761F776BCE /* Pods-YMValidator_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = B6C6ND5V82;
INFOPLIST_FILE = YMValidator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
12 changes: 6 additions & 6 deletions Example/YMValidator/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,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]?) -> 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
26 changes: 10 additions & 16 deletions Example/YMValidator/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="mbt-4h-G0C">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="mbt-4h-G0C">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<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 @@ -15,35 +16,30 @@
<viewControllerLayoutGuide type="bottom" id="m5p-rZ-WNY"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="RXk-Pn-M1k">
<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>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Email:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="06B-wH-3JX">
<rect key="frame" x="30" y="40" width="539" height="28"/>
<fontDescription key="fontDescription" name="Avenir-Light" family="Avenir" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Password:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lo9-6m-LZn">
<rect key="frame" x="30" y="168" width="539" height="28"/>
<fontDescription key="fontDescription" name="Avenir-Light" family="Avenir" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="error label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Oe5-ts-d2M">
<rect key="frame" x="30" y="107" width="539" height="28"/>
<fontDescription key="fontDescription" name="Avenir-Heavy" family="Avenir" pointSize="20"/>
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="1" 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="error label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VO0-Xe-SHs">
<rect key="frame" x="30" y="230" width="539" height="28"/>
<fontDescription key="fontDescription" name="Avenir-Heavy" family="Avenir" pointSize="20"/>
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="W0z-K7-cEE" customClass="YMValidator" customModule="YMValidator">
<rect key="frame" x="30" y="69" width="539" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<userDefinedRuntimeAttributes>
Expand All @@ -52,7 +48,6 @@
</userDefinedRuntimeAttributes>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Oca-JW-wpF" customClass="YMValidator" customModule="YMValidator">
<rect key="frame" x="30" y="192" width="539" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<userDefinedRuntimeAttributes>
Expand All @@ -61,20 +56,19 @@
</userDefinedRuntimeAttributes>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="abJ-ek-QRx">
<rect key="frame" x="0.0" y="480" width="600" height="120"/>
<color key="backgroundColor" red="0.5" green="0.0" blue="0.5" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.5" green="0.0" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="120" id="krb-CB-Mb6"/>
</constraints>
<state key="normal" title="Valid?">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="validAction:" destination="mbt-4h-G0C" eventType="touchUpInside" id="h8V-ZL-kEb"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Lo9-6m-LZn" firstAttribute="top" secondItem="Oe5-ts-d2M" secondAttribute="bottom" constant="33" id="1qj-fi-Mwr"/>
<constraint firstItem="W0z-K7-cEE" firstAttribute="trailing" secondItem="Oe5-ts-d2M" secondAttribute="trailing" id="3cq-a7-hxO"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -35,4 +45,4 @@
"version" : 1,
"author" : "xcode"
}
}
}
20 changes: 10 additions & 10 deletions Example/YMValidator/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import YMValidator

@objc(EmailValidator)
private class EmailValidator: NSObject, YMRulesValidator {
private var regex: String = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
fileprivate var regex: String = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
}

@objc(PasswordValidator)
Expand Down Expand Up @@ -61,16 +61,16 @@ class ViewController: UIViewController {
super.didReceiveMemoryWarning()
}

private func addCustomTextField() {
fileprivate func addCustomTextField() {
//Info label
let label = UILabel(frame: CGRect(x: 30.0, y: 271.0, width: 540, height: 21))
label.text = "Custom input:"

//Error label
let customErrorLabel = UILabel(frame: CGRect(x: 30.0, y: 334.0, width: 540, height: 21))
customErrorLabel.text = ""
customErrorLabel.textColor = UIColor.redColor()
customErrorLabel.textAlignment = .Center
customErrorLabel.textColor = UIColor.red
customErrorLabel.textAlignment = .center

//TextField
let textField = YMValidator(frame: CGRect(x: 30.0, y: 296.0, width: 540, height: 30), rulesValidator: CustomValidator(), errorMessage: "Only alphanumeric characters are allowed", errorLabel: customErrorLabel)
Expand All @@ -88,7 +88,7 @@ class ViewController: UIViewController {
// Add your constraints...
}

@IBAction func validAction(sender: AnyObject) {
@IBAction func validAction(_ sender: AnyObject) {
if YMValidator.areValid(self) {
self.showSimpleAlert(title: "YMValidator", message: "All textFields are valid!!")
} else {
Expand All @@ -98,7 +98,7 @@ class ViewController: UIViewController {
}

extension ViewController: UITextFieldDelegate {
func textFieldShouldReturn(textField: UITextField) -> Bool {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return false
}
Expand All @@ -112,10 +112,10 @@ extension UIViewController {
- Parameter message: Alert message.
- Returns: Void.
*/
func showSimpleAlert(title title : String, message: String){
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
func showSimpleAlert(title : String, message: String){
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in
}))
self.presentViewController(alert, animated: true, completion: nil)
self.present(alert, animated: true, completion: nil)
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Version](https://img.shields.io/cocoapods/v/YMValidator.svg?style=flat)](http://cocoapods.org/pods/YMValidator)
[![License](https://img.shields.io/cocoapods/l/YMValidator.svg?style=flat)](http://cocoapods.org/pods/YMValidator)
[![Platform](https://img.shields.io/cocoapods/p/YMValidator.svg?style=flat)](http://cocoapods.org/pods/YMValidator)
[![Swift 2.2](https://img.shields.io/badge/Swift-2.2-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift/)


TextField Validation library for Swift (@IBDesignable & Programmatically)
Expand Down Expand Up @@ -73,7 +73,7 @@ Installation
###### Requirements

* iOS 8.0+
* Xcode 7 (Swift 2.2)
* Xcode 8 (Swift 3)

##### Cocoapods

Expand All @@ -85,7 +85,7 @@ pod "YMValidator"
```

##### Manually
Drag and drop `YMValidator.swift` into your Project.
Drag and drop `YMValidator.swift` into your project.

Author
------------
Expand Down
2 changes: 1 addition & 1 deletion YMValidator.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'YMValidator'
s.version = '0.2.0'
s.version = '0.2.1'
s.summary = 'TextField Validation library for Swift (@IBDesignable & Programmatically)'

# This description is used to generate tags and improve search results.
Expand Down

0 comments on commit 06c2a30

Please sign in to comment.