Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions SampleApp-Swift/SampleApp-Swift/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]?) -> 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
38 changes: 21 additions & 17 deletions SampleApp-Swift/SampleApp-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

class ViewController: UIViewController, CardIOPaymentViewControllerDelegate {
class ViewController: UIViewController {

@IBOutlet weak var resultLabel: UILabel!
override func viewDidLoad() {
Expand All @@ -21,22 +21,26 @@ class ViewController: UIViewController, CardIOPaymentViewControllerDelegate {
// Dispose of any resources that can be recreated.
}

@IBAction func scanCard(sender: AnyObject) {
let cardIOVC = CardIOPaymentViewController(paymentDelegate: self)
cardIOVC.modalPresentationStyle = .FormSheet
presentViewController(cardIOVC, animated: true, completion: nil)
}

func userDidCancelPaymentViewController(paymentViewController: CardIOPaymentViewController!) {
resultLabel.text = "user canceled"
paymentViewController?.dismissViewControllerAnimated(true, completion: nil)
@IBAction func scanCard(_ sender: Any) {
if let cardIOVC = CardIOPaymentViewController(paymentDelegate: self) {
cardIOVC.modalPresentationStyle = .formSheet
present(cardIOVC, animated: true, completion: nil)
} else {
print("Something's not good.")
}
}

func userDidProvideCreditCardInfo(cardInfo: CardIOCreditCardInfo!, inPaymentViewController paymentViewController: CardIOPaymentViewController!) {
if let info = cardInfo {
let str = NSString(format: "Received card info.\n Number: %@\n expiry: %02lu/%lu\n cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv)
resultLabel.text = str as String
}

extension ViewController: CardIOPaymentViewControllerDelegate {
func userDidCancel(_ paymentViewController: CardIOPaymentViewController) {
self.resultLabel.text = "user canceled"
paymentViewController.dismiss(animated: true, completion: nil)
}

func userDidProvide(_ cardInfo: CardIOCreditCardInfo, in paymentViewController: CardIOPaymentViewController) {
let cardDetails = "Received card info.\n Number: \(cardInfo.redactedCardNumber)\n expiry: \(cardInfo.expiryMonth)/\(cardInfo.expiryYear)\n cvv: \(cardInfo.cvv)."
self.resultLabel.text = cardDetails

paymentViewController.dismiss(animated: true, completion: nil)
}
paymentViewController?.dismissViewControllerAnimated(true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SampleApp_SwiftTests: XCTestCase {

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