@@ -66,19 +66,18 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
6666
6767 self . resultLabel. text = " "
6868
69- let recordAmount : StudyplusRecordAmount = StudyplusRecordAmount ( amount: 10 )
70- let record : StudyplusRecord = StudyplusRecord ( duration: duration,
71- recordedAt: Date ( ) ,
72- amount: recordAmount,
73- comment: " Today, I studied like anything. " )
74-
75- Studyplus . shared. post ( studyRecord: record, success: {
76-
77- self . resultLabel. text = " Success to post your studyRecord to Studyplus App "
78-
79- } , failure: { error in
80-
81- self . resultLabel. text = " Error Code: \( error. code ( ) ) , Message: \( error. message ( ) ) "
69+ let record = StudyplusRecord ( duration: Int ( duration) ,
70+ amount: 10 ,
71+ comment: " Today, I studied like anything. " ,
72+ recordDatetime: Date ( ) )
73+
74+ Studyplus . shared. post ( record, completion: { result in
75+ switch result {
76+ case . failure( let error) :
77+ self . resultLabel. text = " Error Code: \( error) "
78+ case . success:
79+ self . resultLabel. text = " Success to post your studyRecord to Studyplus App "
80+ }
8281 } )
8382 }
8483
@@ -96,9 +95,9 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
9695 updateIsConnected ( )
9796 }
9897
99- func studyplusDidFailToLogin( error: StudyplusError ) {
98+ func studyplusDidFailToLogin( error: StudyplusLoginError ) {
10099 print ( " -- Called studyplusDidFailToLogin -- " )
101- resultLabel. text = " Error Code: \( error. code ( ) ) , Message: \( error . message ( ) ) "
100+ resultLabel. text = " Error Code: \( error) "
102101 updateIsConnected ( )
103102 }
104103
0 commit comments