44//
55// The MIT License (MIT)
66//
7- // Copyright (c) 2017 Studyplus inc.
7+ // Copyright (c) 2021 Studyplus inc.
88//
99// Permission is hereby granted, free of charge, to any person obtaining a copy
1010// of this software and associated documentation files (the "Software"), to deal
2727import UIKit
2828import StudyplusSDK
2929
30- class ViewController : UIViewController , StudyplusLoginDelegate {
30+ class ViewController : UIViewController {
3131
3232 @IBOutlet weak var isConnectedLabel : UILabel !
3333 @IBOutlet weak var resultLabel : UILabel !
@@ -39,14 +39,6 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
3939 Studyplus . shared. delegate = self
4040 }
4141
42- // MARK: - Label
43-
44- private func updateIsConnected( ) {
45- isConnectedLabel. text = Studyplus . shared. isConnected ( ) ? " True " : " False "
46- }
47-
48- // MARK: - Button Action
49-
5042 @IBAction func loginButton( _ sender: UIButton ) {
5143 Studyplus . shared. login ( )
5244 }
@@ -81,29 +73,25 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
8173 } )
8274 }
8375
84- // MARK: - Picker
85-
8676 @IBAction func studyRecordDurationPicker( _ sender: UIDatePicker ) {
8777 duration = sender. countDownDuration
8878 }
8979
90- // MARK: - StudyplusLoginDelegate
80+ private func updateIsConnected( ) {
81+ isConnectedLabel. text = Studyplus . shared. isConnected ( ) ? " True " : " False "
82+ }
83+ }
9184
92- func studyplusDidSuccessToLogin( ) {
85+ extension ViewController : StudyplusLoginDelegate {
86+ func studyplusLoginSuccess( ) {
9387 print ( " -- Called studyplusDidSuccessToLogin -- " )
9488 resultLabel. text = " Login succeeded "
9589 updateIsConnected ( )
9690 }
9791
98- func studyplusDidFailToLogin ( error: StudyplusLoginError ) {
92+ func studyplusLoginFail ( error: StudyplusLoginError ) {
9993 print ( " -- Called studyplusDidFailToLogin -- " )
10094 resultLabel. text = " Error Code: \( error) "
10195 updateIsConnected ( )
10296 }
103-
104- func studyplusDidCancelToLogin( ) {
105- print ( " -- Called studyplusDidCancelToLogin -- " )
106- resultLabel. text = " Login canceled "
107- updateIsConnected ( )
108- }
10997}
0 commit comments