From 67883f7e8ab7ca98aedb1b53232dd26f6182395e Mon Sep 17 00:00:00 2001 From: Juha Salo Date: Thu, 24 Mar 2016 18:55:13 +0200 Subject: [PATCH 01/11] Migrate to new version of libraries and swift 2.2 --- Cartfile | 6 +- Cartfile.private | 4 +- Cartfile.resolved | 10 +- Clutch/Crypto.swift | 16 +- Clutch/Extensions.swift | 34 +- Clutch/IQKeybordManagerSwift/.DS_Store | Bin 0 -> 6148 bytes .../Categories/IQUIScrollView+Additions.swift | 47 + .../IQUITextFieldView+Additions.swift | 56 + .../IQUIViewController+Additions.swift} | 37 +- .../IQToolbar/IQToolbar.swift | 101 -- .../IQButtonBarArrowLeft@2x.png | Bin 328 -> 0 bytes .../IQButtonBarArrowRight@2x.png | Bin 351 -> 0 bytes Clutch/Networking.swift | 8 +- Clutch/SPHAddCardViewController.swift | 32 +- Clutch/SPHClutch.storyboard | 7 +- Clutch/SPHClutch.swift | 54 +- Clutch/SPHClutchFormLabel.swift | 2 +- Clutch/SPHClutchFormatter.swift | 20 +- Clutch/SPHClutchTextField.swift | 4 +- .../Categories/IQNSArray+Sort.swift | 33 +- .../Categories/IQUIScrollView+Additions.swift | 47 + .../IQUITextFieldView+Additions.swift | 56 + .../Categories/IQUIView+Hierarchy.swift | 103 +- .../IQUIViewController+Additions.swift | 46 + .../Categories/IQUIWindow+Hierarchy.swift | 8 +- .../IQKeyboardManagerConstants.swift | 5 +- .../IQKeyboardManagerConstantsInternal.swift | 22 +- .../IQKeyboardManager.swift | 994 ++++++++++-------- .../IQKeyboardReturnKeyHandler.swift | 139 +-- .../IQTextView/IQTextView.swift | 35 +- .../IQToolbar/IQBarButtonItem.swift | 79 ++ .../IQToolbar/IQTitleBarButtonItem.swift | 44 +- .../IQToolbar/IQToolbar.swift | 191 ++++ .../IQUIView+IQKeyboardToolbar.swift | 668 ++++++++---- .../IQButtonBarArrowLeft.png | Bin 0 -> 886 bytes .../IQButtonBarArrowLeft@2x.png | Bin 0 -> 1793 bytes .../IQButtonBarArrowLeft@3x.png | Bin 0 -> 1815 bytes .../IQButtonBarArrowRight.png | Bin 0 -> 943 bytes .../IQButtonBarArrowRight@2x.png | Bin 0 -> 1786 bytes .../IQButtonBarArrowRight@3x.png | Bin 0 -> 1844 bytes .../de.lproj/IQKeyboardManager.strings | 0 .../en.lproj/IQKeyboardManager.strings | 0 .../es.lproj/IQKeyboardManager.strings | 0 .../fr.lproj/IQKeyboardManager.strings | 13 + .../zh-Hans/IQKeyboardManager.strings | 0 .../zh-Hant/IQKeyboardManager.strings | 0 readme.md | 5 +- 47 files changed, 1892 insertions(+), 1034 deletions(-) create mode 100644 Clutch/IQKeybordManagerSwift/.DS_Store create mode 100755 Clutch/IQKeybordManagerSwift/Categories/IQUIScrollView+Additions.swift create mode 100755 Clutch/IQKeybordManagerSwift/Categories/IQUITextFieldView+Additions.swift rename Clutch/IQKeybordManagerSwift/{IQToolbar/IQBarButtonItem.swift => Categories/IQUIViewController+Additions.swift} (59%) mode change 100644 => 100755 delete mode 100644 Clutch/IQKeybordManagerSwift/IQToolbar/IQToolbar.swift delete mode 100644 Clutch/IQKeybordManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowLeft@2x.png delete mode 100644 Clutch/IQKeybordManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowRight@2x.png rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Categories/IQNSArray+Sort.swift (66%) mode change 100644 => 100755 create mode 100755 IQKeyboardManagerSwift/Categories/IQUIScrollView+Additions.swift create mode 100755 IQKeyboardManagerSwift/Categories/IQUITextFieldView+Additions.swift rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Categories/IQUIView+Hierarchy.swift (77%) mode change 100644 => 100755 create mode 100755 IQKeyboardManagerSwift/Categories/IQUIViewController+Additions.swift rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Categories/IQUIWindow+Hierarchy.swift (91%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Constants/IQKeyboardManagerConstants.swift (98%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Constants/IQKeyboardManagerConstantsInternal.swift (67%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/IQKeyboardManager.swift (64%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/IQKeyboardReturnKeyHandler.swift (74%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/IQTextView/IQTextView.swift (71%) mode change 100644 => 100755 create mode 100755 IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/IQToolbar/IQTitleBarButtonItem.swift (55%) mode change 100644 => 100755 create mode 100755 IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/IQToolbar/IQUIView+IQKeyboardToolbar.swift (51%) mode change 100644 => 100755 create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowLeft.png create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowLeft@2x.png create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowLeft@3x.png create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowRight.png create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowRight@2x.png create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowRight@3x.png rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Resources/IQKeyboardManager.bundle/de.lproj/IQKeyboardManager.strings (100%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Resources/IQKeyboardManager.bundle/en.lproj/IQKeyboardManager.strings (100%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Resources/IQKeyboardManager.bundle/es.lproj/IQKeyboardManager.strings (100%) mode change 100644 => 100755 create mode 100755 IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle/fr.lproj/IQKeyboardManager.strings rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Resources/IQKeyboardManager.bundle/zh-Hans/IQKeyboardManager.strings (100%) mode change 100644 => 100755 rename {Clutch/IQKeybordManagerSwift => IQKeyboardManagerSwift}/Resources/IQKeyboardManager.bundle/zh-Hant/IQKeyboardManager.strings (100%) mode change 100644 => 100755 diff --git a/Cartfile b/Cartfile index 81cd5e0..f2a39a7 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ -github "Alamofire/Alamofire" >= 1.2 -github "SwiftyJSON/SwiftyJSON" >= 2.2.1 -github "pyrtsa/CryptoSwift" "device-tests" +github "Alamofire/Alamofire" ~> 3.3.0 +github "SwiftyJSON/SwiftyJSON" ~> 2.3.1 +github "krzyzanowskim/CryptoSwift" ~> 0.3 diff --git a/Cartfile.private b/Cartfile.private index 5aca623..cf5a254 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ -github "Quick/Quick" "6c7b90f27c46e2317f56c86a8d82e5881e4015b0" # master branch -github "Quick/Nimble" "b89db8654c5f134d4f68e706b6da4a5581cb2001" # master branch +github "Quick/Quick" ~> 0.9.1 +github "Quick/Nimble" ~> 3.2.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 903aa64..e8d824c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ -github "Alamofire/Alamofire" "1.3.1" -github "pyrtsa/CryptoSwift" "e28bd0961a4448d3c071b91a029736d5d60deec9" -github "Quick/Nimble" "b89db8654c5f134d4f68e706b6da4a5581cb2001" -github "Quick/Quick" "6c7b90f27c46e2317f56c86a8d82e5881e4015b0" -github "SwiftyJSON/SwiftyJSON" "2.2.1" +github "Alamofire/Alamofire" "3.3.0" +github "krzyzanowskim/CryptoSwift" "0.3" +github "Quick/Nimble" "v3.2.0" +github "Quick/Quick" "v0.9.1" +github "SwiftyJSON/SwiftyJSON" "2.3.3" diff --git a/Clutch/Crypto.swift b/Clutch/Crypto.swift index 15f30ba..b32860a 100644 --- a/Clutch/Crypto.swift +++ b/Clutch/Crypto.swift @@ -15,21 +15,21 @@ public func getRequestId() -> String { /// Returns Optional SecKeyRef from given certificate in DER-format. /// -/// :param: DER-formatted certificate -/// :returns: SecKeyRef or Nil. +/// - parameter DER-formatted: certificate +/// - returns: SecKeyRef or Nil. private func loadDER(publicKeyFileContent: NSData) -> SecKeyRef? { let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, publicKeyFileContent as CFData).takeUnretainedValue() let policy = SecPolicyCreateBasicX509().takeUnretainedValue(); var unmanagedTrust : Unmanaged? = nil let status = SecTrustCreateWithCertificates(certificate, policy, &unmanagedTrust) if (status != 0) { - println("SecTrustCreateWithCertificates fail. Error Code: \(status)"); + print("SecTrustCreateWithCertificates fail. Error Code: \(status)"); return nil } let trust = unmanagedTrust!.takeUnretainedValue() let evaluateStatus = SecTrustEvaluate(trust, nil) if (evaluateStatus != 0) { - println("SecTrustEvaluate fail. Error Code: \(evaluateStatus)"); + print("SecTrustEvaluate fail. Error Code: \(evaluateStatus)"); return nil } return SecTrustCopyPublicKey(trust).takeUnretainedValue(); @@ -38,19 +38,19 @@ private func loadDER(publicKeyFileContent: NSData) -> SecKeyRef? { private func encryptWithData(content :NSData, publicKey :SecKeyRef) -> NSData? { let blockSize = Int(SecKeyGetBlockSize(publicKey) - 11) - var encryptedData = NSMutableData() + let encryptedData = NSMutableData() let blockCount = Int(ceil(Double(content.length) / Double(blockSize))) for i in 0..(buffer.bytes), buffer.length, &cipher, &cipherLen) + let buffer = content.subdataWithRange(NSMakeRange(i*blockSize, bufferSize)) + let status = SecKeyEncrypt(publicKey, SecPadding.OAEP, UnsafePointer(buffer.bytes), buffer.length, &cipher, &cipherLen) if (status == noErr){ encryptedData.appendBytes(cipher, length: Int(cipherLen)) }else{ - println("SecKeyEncrypt fail. Error Code: \(status)") + print("SecKeyEncrypt fail. Error Code: \(status)") return nil } } diff --git a/Clutch/Extensions.swift b/Clutch/Extensions.swift index c25b8b5..8e9a6a0 100644 --- a/Clutch/Extensions.swift +++ b/Clutch/Extensions.swift @@ -25,27 +25,27 @@ public struct Inset { internal extension String { /// Get a given substring of a string - /// :param: r The range of the substring wanted - /// :returns: The found substring + /// - parameter r: The range of the substring wanted + /// - returns: The found substring subscript (r: Range) -> String { get { - let startIndex = advance(self.startIndex, r.startIndex) - let endIndex = advance(startIndex, r.endIndex - r.startIndex) + let startIndex = self.startIndex.advancedBy(r.startIndex) + let endIndex = startIndex.advancedBy(r.endIndex - r.startIndex) return self[Range(start: startIndex, end: endIndex)] } } /// Returns matches for given regexp - /// :param: regex The pattern to evaluate - /// :returns: Found matches as an array + /// - parameter regex: The pattern to evaluate + /// - returns: Found matches as an array func matchesForRegex(regex: String!) -> [String] { - let regex = NSRegularExpression(pattern: regex, - options: nil, error: nil)! + let regex = try! NSRegularExpression(pattern: regex, + options: []) let nsString = self as NSString let results = regex.matchesInString(nsString as String, - options: nil, range: NSMakeRange(0, nsString.length)) - as! [NSTextCheckingResult] + options: [], range: NSMakeRange(0, nsString.length)) + var strings = [String]() @@ -63,8 +63,8 @@ internal extension String { /// appends optional trailing string if longer /// Source: https://gist.github.com/aorcsik/c8210a84f163b1b644c0 func truncate(length: Int, trailing: String? = nil) -> String { - if count(self) > length { - return self.substringToIndex(advance(self.startIndex, length)) + (trailing ?? "") + if self.characters.count > length { + return self.substringToIndex(self.startIndex.advancedBy(length)) + (trailing ?? "") } else { return self } @@ -77,9 +77,9 @@ internal extension String { internal extension UIColor { /// Convenience method for initializing with 0-255 color values - /// :param: red The red color value - /// :param: green The green color value - /// :param: blue The blue color value + /// - parameter red: The red color value + /// - parameter green: The green color value + /// - parameter blue: The blue color value convenience init(red: Int, green: Int, blue: Int) { assert(red >= 0 && red <= 255, "Invalid red component") assert(green >= 0 && green <= 255, "Invalid green component") @@ -89,7 +89,7 @@ internal extension UIColor { } /// Convenience method for initializing with a 0xFFFFFF-0x000000 color value - /// :param: hexInt The hexadecimal integer color value + /// - parameter hexInt: The hexadecimal integer color value convenience init(hexInt: Int) { self.init(red: (hexInt >> 16) & 0xff, green: (hexInt >> 8) & 0xff, blue: hexInt & 0xff) } @@ -106,7 +106,7 @@ public extension UIViewController { controller.successHandler = success controller.errorHandler = error - var nav = UINavigationController(rootViewController: controller) + let nav = UINavigationController(rootViewController: controller) nav.modalPresentationStyle = UIModalPresentationStyle.Popover let ppc = nav.popoverPresentationController! let minimunSize = controller.view.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize) diff --git a/Clutch/IQKeybordManagerSwift/.DS_Store b/Clutch/IQKeybordManagerSwift/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 CGSize { - var sizeThatFit = super.sizeThatFits(size) - sizeThatFit.height = 44 - return sizeThatFit - } - - override var tintColor: UIColor! { - - didSet { - if items != nil { - for item in items as! [UIBarButtonItem] { - - if item is IQTitleBarButtonItem { - (item as! IQTitleBarButtonItem).tintColor = tintColor - } - } - } - } - } - - var enableInputClicksWhenVisible: Bool { - return true - } -} diff --git a/Clutch/IQKeybordManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowLeft@2x.png b/Clutch/IQKeybordManagerSwift/Resources/IQKeyboardManager.bundle/IQButtonBarArrowLeft@2x.png deleted file mode 100644 index c4a81c449abea0ccae5dc72223d34be37aada6a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^;y|p$!3HEF&Kk(_ z_>br}%*YZ`kmfOxX^C!}k<@VZL8e2nq^4=*m4ph8KDMI<++8cToKjfK*6eK-@X~BY zbCcwYL#+-x+TAOkB~3W!otbEG!KY2nq$qt~f4Yn!vif(PFYot&8^amX$0FZk9_fYr04L0ouUe>FVdQ&MBb@0OLxHrS(RU5O5k|Fa@e?I8q;6zttnl)9d5b~o`H)UTZCk8SO6*A zkbol_ST7na;F|U9$OcUB;dNmEs=>sib1rwQ{GT6Z1n*8ZKC (), failure: (NSError) -> ()) -> () { var reqId = getRequestId() // requestId not validated for this call - manager.request(.GET, "\(host)/mobile-key").responseJSON{(request, response, data, error) in + manager.request(.GET, "\(host)/mobile-key").responseJSON{request, response, data, error in if let errorMessage = error { println("Networking.helperGetTransactionId most likely received malformed data from server.") failure(errorMessage) @@ -110,7 +110,7 @@ public class Networking { public func tokenize(transactionId: String, expiryMonth: String, expiryYear: String, cvc: String, pan: String, certificateBase64Der: String, success: (String) -> (), failure: (NSError) -> ()) -> () { let jsonCardData = JSON(["expiry_month": expiryMonth, "expiry_year": expiryYear, "cvc" : cvc, "pan" : pan]) - if let encrypted = encryptWithRsaAes(jsonCardData.description, certificateBase64Der) + if let encrypted = encryptWithRsaAes(jsonCardData.description, certificateBase64Der: certificateBase64Der) { let payloadJson = ["encrypted" : encrypted.encryptedBase64Message, "key" : ["key" : encrypted.encryptedBase64Key, "iv" : encrypted.iv]] @@ -173,7 +173,7 @@ public class Networking { { return true } - println("Error: received requestID did not match.") + print("Error: received requestID did not match.") return false } } diff --git a/Clutch/SPHAddCardViewController.swift b/Clutch/SPHAddCardViewController.swift index 0736ba9..fda29f1 100644 --- a/Clutch/SPHAddCardViewController.swift +++ b/Clutch/SPHAddCardViewController.swift @@ -24,8 +24,8 @@ import UIKit @IBOutlet weak var scrollContainer: UIScrollView! internal var transactionId = "" - internal var successHandler : (String) -> () = {println($0)} - internal var errorHandler : (NSError) -> () = {println($0)} + internal var successHandler : (String) -> () = {print($0)} + internal var errorHandler : (NSError) -> () = {print($0)} let correctBorderColor = UIColor(hexInt: 0xa6b9dc).CGColor @@ -37,7 +37,7 @@ import UIKit func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { // Override default behavior for popover on small screens - println(controller.presentedViewController) + print(controller.presentedViewController) let navcon = controller.presentedViewController as! UINavigationController let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light)) visualEffectView.frame = navcon.view.bounds @@ -71,13 +71,13 @@ import UIKit switch field { case cardNumberField: iconImage = UIImage(named: "cardicon", inBundle: clutchBundle, compatibleWithTraitCollection: nil) - field.addTarget(self, action: "formatCardNumberFieldOnTheFly:", forControlEvents: UIControlEvents.EditingChanged) + field.addTarget(self, action: #selector(SPHAddCardViewController.formatCardNumberFieldOnTheFly(_:)), forControlEvents: UIControlEvents.EditingChanged) case cardExpiryDateField: iconImage = UIImage(named: "calendaricon", inBundle: clutchBundle, compatibleWithTraitCollection: nil) - field.addTarget(self, action: "formatExpirationDateFieldOnTheFly:", forControlEvents: UIControlEvents.EditingChanged) + field.addTarget(self, action: #selector(SPHAddCardViewController.formatExpirationDateFieldOnTheFly(_:)), forControlEvents: UIControlEvents.EditingChanged) case cardSecurityCodeField: iconImage = UIImage(named: "lockicon", inBundle: clutchBundle, compatibleWithTraitCollection: nil) - field.addTarget(self, action: "formatSecurityCodeFieldOnTheFly:", forControlEvents: UIControlEvents.EditingChanged) + field.addTarget(self, action: #selector(SPHAddCardViewController.formatSecurityCodeFieldOnTheFly(_:)), forControlEvents: UIControlEvents.EditingChanged) default: break } @@ -97,12 +97,12 @@ import UIKit addCardButton.layer.cornerRadius = 4.0 addCardButton.layer.masksToBounds = true - addCardButton.addTarget(self, action: "addCardButtonTapped:", forControlEvents: .TouchUpInside) + addCardButton.addTarget(self, action: #selector(SPHAddCardViewController.addCardButtonTapped(_:)), forControlEvents: .TouchUpInside) addCardButton.layer.insertSublayer(gradientLayer, atIndex: 0) // Setup cancel - navCancel.addTarget(self, action: "navCancelButtonTapped:", + navCancel.addTarget(self, action: #selector(SPHAddCardViewController.navCancelButtonTapped(_:)), forControlEvents: .TouchUpInside) setupLocalization() @@ -121,7 +121,7 @@ import UIKit func formatCardNumberFieldOnTheFly(textView: AnyObject){ if let sphField = textView as? SPHClutchTextField{ - sphField.text = SPHClutch.sharedInstance.formattedCardNumber(sphField.text, cardType: SPHClutch.sharedInstance.cardTypeForCardNumber(SPHClutch.sharedInstance.formattedCardNumberForProcessing(sphField.text))) + sphField.text = SPHClutch.sharedInstance.formattedCardNumber(sphField.text!, cardType: SPHClutch.sharedInstance.cardTypeForCardNumber(SPHClutch.sharedInstance.formattedCardNumberForProcessing(sphField.text!))) updateCardNumberValidity(sphField) } @@ -129,7 +129,7 @@ import UIKit func formatExpirationDateFieldOnTheFly(textView: AnyObject){ if let sphField = textView as? SPHClutchTextField{ - sphField.text = SPHClutch.sharedInstance.formattedExpirationDate(sphField.text) + sphField.text = SPHClutch.sharedInstance.formattedExpirationDate(sphField.text!) updateExpirationValidity(sphField) } @@ -138,7 +138,7 @@ import UIKit func formatSecurityCodeFieldOnTheFly(textView: AnyObject){ if let sphField = textView as? SPHClutchTextField{ - sphField.text = SPHClutch.sharedInstance.formattedSecurityCode(sphField.text) + sphField.text = SPHClutch.sharedInstance.formattedSecurityCode(sphField.text!) updateSecurityCodeValidity(sphField) } @@ -174,7 +174,7 @@ import UIKit } func genericUpdateCodeValidity(sphField: SPHClutchTextField, validityFunction: (String) -> Bool){ - if validityFunction(sphField.text) == true { + if validityFunction(sphField.text!) == true { sphField.fieldState = SPHClutchTextFieldState.Valid } else { sphField.fieldState = SPHClutchTextFieldState.Invalid @@ -199,7 +199,7 @@ import UIKit } func addCardButtonTapped(sender: AnyObject) { - if let gradient = self.addCardButton.layer.sublayers.first as? CAGradientLayer { + if let gradient = self.addCardButton.layer.sublayers!.first as? CAGradientLayer { UIView.animateWithDuration(0.25, delay: 0.0, options: .BeginFromCurrentState, animations: { gradient.colors = [UIColor(hexInt: 0x3c89cf).CGColor, UIColor(hexInt: 0x4f9ee5).CGColor] @@ -218,10 +218,10 @@ import UIKit return } else { - let month = cardExpiryDateField.text.componentsSeparatedByString("/")[0] - let year = "20" + cardExpiryDateField.text.componentsSeparatedByString("/")[1] + let month = cardExpiryDateField.text!.componentsSeparatedByString("/")[0] + let year = "20" + cardExpiryDateField.text!.componentsSeparatedByString("/")[1] - SPHClutch.sharedInstance.addCard(transactionId, pan: SPHClutch.sharedInstance.formattedCardNumberForProcessing(cardNumberField.text), cvc: cardSecurityCodeField.text, expiryMonth: month, expiryYear: year, success: successHandler, failure: errorHandler) + SPHClutch.sharedInstance.addCard(transactionId, pan: SPHClutch.sharedInstance.formattedCardNumberForProcessing(cardNumberField.text!), cvc: cardSecurityCodeField.text!, expiryMonth: month, expiryYear: year, success: successHandler, failure: errorHandler) } self.dismissViewControllerAnimated(true, completion: nil) diff --git a/Clutch/SPHClutch.storyboard b/Clutch/SPHClutch.storyboard index d5ce9d4..fd40bf8 100644 --- a/Clutch/SPHClutch.storyboard +++ b/Clutch/SPHClutch.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -177,7 +178,7 @@