Skip to content

Commit

Permalink
fix. syntax for swift3
Browse files Browse the repository at this point in the history
  • Loading branch information
liu044100 committed Sep 14, 2016
1 parent f5b43c8 commit f1adeea
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 169 deletions.
12 changes: 12 additions & 0 deletions SmileLock-Example/Pods/Pods.xcodeproj/project.pbxproj

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

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

18 changes: 17 additions & 1 deletion SmileLock-Example/SmileLock-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,21 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = rain;
TargetAttributes = {
B7E3A1A91CCC6448005F680E = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
};
B7E3A1BD1CCC6449005F680E = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
TestTargetID = B7E3A1A91CCC6448005F680E;
};
B7E3A1C81CCC6449005F680E = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
TestTargetID = B7E3A1A91CCC6448005F680E;
};
};
Expand Down Expand Up @@ -409,8 +412,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -455,8 +460,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -475,6 +482,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -484,25 +492,29 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7C52457304DEFE4405D2D34B /* Pods-SmileLock-Example.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = "SmileLock-Example/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "edu.self.SmileLock-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
B7E3A1D41CCC6449005F680E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F1E646CC82DCC7E6193CF7E7 /* Pods-SmileLock-Example.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = "SmileLock-Example/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "edu.self.SmileLock-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -514,6 +526,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "edu.self.SmileLock-ExampleTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SmileLock-Example.app/SmileLock-Example";
};
name = Debug;
Expand All @@ -526,6 +539,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "edu.self.SmileLock-ExampleTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SmileLock-Example.app/SmileLock-Example";
};
name = Release;
Expand All @@ -537,6 +551,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "edu.self.SmileLock-ExampleUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_TARGET_NAME = "SmileLock-Example";
};
name = Debug;
Expand All @@ -548,6 +563,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "edu.self.SmileLock-ExampleUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_TARGET_NAME = "SmileLock-Example";
};
name = Release;
Expand Down
12 changes: 6 additions & 6 deletions SmileLock-Example/SmileLock-Example/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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BlurPasswordLoginViewController: UIViewController {

self.passwordUIValidation.success = { [weak self] _ in
print("*️⃣ success!")
self?.dismissViewControllerAnimated(true, completion: nil)
self?.dismiss(animated: true, completion: nil)
}

self.passwordUIValidation.failure = { _ in
Expand Down
12 changes: 6 additions & 6 deletions SmileLock-Example/SmileLock-Example/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class HomeViewController: UIViewController {
self.loginVCID = isBlurUI ? "BlurPasswordLoginViewController" : "PasswordLoginViewController"
}

@IBAction func presentLoginVC(sender: AnyObject) {
@IBAction func presentLoginVC(_ sender: AnyObject) {
self.present(self.loginVCID)
}

func present(id: String) {
let loginVC = self.storyboard?.instantiateViewControllerWithIdentifier(id)
loginVC?.modalTransitionStyle = .CrossDissolve
loginVC?.modalPresentationStyle = .OverCurrentContext
self.presentViewController(loginVC!, animated: true, completion: nil)
func present(_ id: String) {
let loginVC = self.storyboard?.instantiateViewController(withIdentifier: id)
loginVC?.modalTransitionStyle = .crossDissolve
loginVC?.modalPresentationStyle = .overCurrentContext
self.present(loginVC!, animated: true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
import SmileLock

class MyPasswordModel {
class func match(password: String) -> MyPasswordModel? {
class func match(_ password: String) -> MyPasswordModel? {
guard password == "123456" else { return nil }
return MyPasswordModel()
}
Expand All @@ -24,7 +24,7 @@ class MyPasswordUIValidation: PasswordUIValidation<MyPasswordModel> {
}
}
//handle Touch ID
override func touchAuthenticationComplete(passwordContainerView: PasswordContainerView, success: Bool, error: NSError?) {
override func touchAuthenticationComplete(_ passwordContainerView: PasswordContainerView, success: Bool, error: NSError?) {
if success {
let dummyModel = MyPasswordModel()
self.success?(dummyModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class PasswordLoginViewController: UIViewController {
}

extension PasswordLoginViewController: PasswordInputCompleteProtocol {
func passwordInputComplete(passwordContainerView: PasswordContainerView, input: String) {
func passwordInputComplete(_ passwordContainerView: PasswordContainerView, input: String) {
if self.validation(input) {
self.validationSuccess()
} else {
self.validationFail()
}
}

func touchAuthenticationComplete(passwordContainerView: PasswordContainerView, success: Bool, error: NSError?) {
func touchAuthenticationComplete(_ passwordContainerView: PasswordContainerView, success: Bool, error: NSError?) {
if success {
self.validationSuccess()
} else {
Expand All @@ -49,13 +49,13 @@ extension PasswordLoginViewController: PasswordInputCompleteProtocol {
}

private extension PasswordLoginViewController {
func validation(input: String) -> Bool {
func validation(_ input: String) -> Bool {
return input == "123456"
}

func validationSuccess() {
print("*️⃣ success!")
self.dismissViewControllerAnimated(true, completion: nil)
self.dismiss(animated: true, completion: nil)
}

func validationFail() {
Expand Down
16 changes: 8 additions & 8 deletions SmileLock-Example/SmileLock-Example/extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ enum ColorType: String {

extension UIColor {

class func hexStr(hexStr: NSString) -> UIColor {
class func hexStr(_ hexStr: NSString) -> UIColor {
return UIColor.hexStr(hexStr, alpha: 1)
}

class func color(hexColor:ColorType) -> UIColor {
return UIColor.hexStr(hexColor.rawValue, alpha: 1.0)
class func color(_ hexColor:ColorType) -> UIColor {
return UIColor.hexStr(hexColor.rawValue as NSString, alpha: 1.0)
}

class func hexStr (Str : NSString, alpha : CGFloat) -> UIColor {
let hexStr = Str.stringByReplacingOccurrencesOfString("#", withString: "")
let scanner = NSScanner(string: hexStr as String)
class func hexStr (_ Str : NSString, alpha : CGFloat) -> UIColor {
let hexStr = Str.replacingOccurrences(of: "#", with: "")
let scanner = Scanner(string: hexStr as String)
var color: UInt32 = 0
if scanner.scanHexInt(&color) {
if scanner.scanHexInt32(&color) {
let r = CGFloat((color & 0xFF0000) >> 16) / 255.0
let g = CGFloat((color & 0x00FF00) >> 8) / 255.0
let b = CGFloat(color & 0x0000FF) / 255.0
return UIColor(red:r,green:g,blue:b,alpha:alpha)
} else {
print("invalid hex string", terminator: "")
return UIColor.whiteColor();
return UIColor.white;
}
}

Expand Down
Loading

0 comments on commit f1adeea

Please sign in to comment.