Skip to content

Commit 454bf67

Browse files
author
Maika Akedo
committed
redo StudyplusRecord duration property type, remove added Initializer
1 parent 55b5469 commit 454bf67

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

Demo/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
6767
self.resultLabel.text = ""
6868

6969
let recordAmount: StudyplusRecordAmount = StudyplusRecordAmount(amount: 10)
70-
let record: StudyplusRecord = StudyplusRecord(duration: Int(duration), recordedAt: Date(), amount: recordAmount, comment: "Today, I studied like anything.")
70+
let record: StudyplusRecord = StudyplusRecord(duration: duration, recordedAt: Date(), amount: recordAmount, comment: "Today, I studied like anything.")
7171

7272
Studyplus.shared.post(studyRecord: record, success: {
7373

StudyplusSDK/Studyplus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ final public class Studyplus {
152152
/// - failure: callback when failure to post the studyRecord
153153
public func post(studyRecord: StudyplusRecord, success: @escaping () -> Void, failure: @escaping (_ error: StudyplusError) -> Void) {
154154

155-
guard StudyplusRecord.durationRange ~= studyRecord.duration else {
155+
guard StudyplusRecord.durationRange ~= Int(studyRecord.duration) else {
156156
failure(.postRecordFailed)
157157
return
158158
}

StudyplusSDK/StudyplusRecord.swift

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public struct StudyplusRecord {
7676
The seconds of the learning.
7777
勉強した時間(秒数)です。
7878
*/
79-
public let duration: Int
79+
public let duration: Double
8080

8181
/**
8282
The date and time of learning.
@@ -109,28 +109,8 @@ public struct StudyplusRecord {
109109
/// - recordedAt: Time the learning is ended. 学習を終えた日時。
110110
/// - amount: The amount of learning. 学習量。
111111
/// - comment: Studyplus timeline comment. Studyplusのタイムライン上で表示されるコメント。
112-
@available(*, deprecated, message: "Use Int type duration initializer instead")
113112
public init(duration: Double, recordedAt: Date = Date(), amount: StudyplusRecordAmount? = nil, comment: String? = nil) {
114113

115-
self.duration = Int(duration)
116-
self.recordedAt = recordedAt
117-
self.amount = amount
118-
self.comment = comment
119-
}
120-
121-
/// Initialize StudyplusRecord object.
122-
///
123-
/// 勉強記録オブジェクトを作成します。
124-
///
125-
/// - Parameters:
126-
/// - duration: Specify the seconds of the learning. 勉強した時間(秒数)を指定してください。
127-
/// - min: 0
128-
/// - max: 86400 (24h)
129-
/// - recordedAt: Time the learning is ended. 学習を終えた日時。
130-
/// - amount: The amount of learning. 学習量。
131-
/// - comment: Studyplus timeline comment. Studyplusのタイムライン上で表示されるコメント。
132-
public init(duration: Int, recordedAt: Date = Date(), amount: StudyplusRecordAmount? = nil, comment: String? = nil) {
133-
134114
self.duration = duration
135115
self.recordedAt = recordedAt
136116
self.amount = amount

0 commit comments

Comments
 (0)