Skip to content

Commit dd78291

Browse files
committed
Рефактор
+ убрал неиспользуемый код
1 parent 9827530 commit dd78291

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

SwiftUI-WorkoutApp/Services/APIService.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,6 @@ private extension APIService {
557557
}
558558
#endif
559559
let decodedInfo = try JSONDecoder().decode(type, from: data)
560-
#if DEBUG
561-
print("--- Преобразованные данные:\n\(decodedInfo)")
562-
#endif
563560
return decodedInfo
564561
}
565562

SwiftUI-WorkoutApp/Utils/Sources/Utils/Data+.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import Foundation
22

33
public extension Data {
44
var prettyJson: String {
5-
do {
6-
let object = try JSONSerialization.jsonObject(with: self, options: [.fragmentsAllowed])
7-
let jsonData = try JSONSerialization.data(withJSONObject: object, options: .prettyPrinted)
8-
let json = String(data: jsonData, encoding: .utf8)
9-
return json.valueOrEmpty
10-
} catch {
11-
print("--- Не удалось вывести в JSON: \(error)")
5+
if let object = try? JSONSerialization.jsonObject(with: self, options: [.fragmentsAllowed]),
6+
let jsonData = try? JSONSerialization.data(withJSONObject: object, options: .prettyPrinted),
7+
let json = String(data: jsonData, encoding: .utf8) {
8+
return json
9+
} else {
10+
return ""
1211
}
13-
return ""
1412
}
1513

1614
mutating func append(_ string: String) {

SwiftUI-WorkoutApp/Utils/Sources/Utils/Date+.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ public extension Date {
44
var isToday: Bool {
55
Calendar.current.isDateInToday(self)
66
}
7+
78
var isYesterday: Bool {
89
Calendar.current.isDateInYesterday(self)
910
}
10-
var isTomorrow: Bool {
11-
Calendar.current.isDateInTomorrow(self)
12-
}
13-
var isWeekend: Bool {
14-
Calendar.current.isDateInWeekend(self)
15-
}
11+
1612
var isThisYear: Bool {
1713
Calendar.current.compare(Date.now, to: self, toGranularity: .year) == .orderedSame
1814
}

SwiftUI-WorkoutApp/Utils/Sources/Utils/String+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
public extension String {
44
var withoutHTML: String {
5-
self.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
5+
replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
66
}
77

88
var capitalizingFirstLetter: String {

0 commit comments

Comments
 (0)