Post

Replies

Boosts

Views

Activity

TimelineView's custom schedule termination
Hello, How should I terminate my custom implementation of TimelineSchedule? Should I return nil or .distantFuture? Is there actual difference? Please find my sample implementation below: struct FixedNumberSchedule: TimelineSchedule { let count: Int func entries( from startDate: Date, mode: Mode ) -> Entries { Entries(startDate: startDate, count: count) } struct Entries: Sequence, IteratorProtocol { var currentDate: Date? let initialCount: Int var count: Int init(startDate: Date,count: Int) { self.currentDate = startDate self.initialCount = count self.count = count } mutating func next() -> Date? { defer { if count > 1 { currentDate?.addTimeInterval(1) count -= 1 } else { self.currentDate = nil } } print("Seq \(initialCount), \(currentDate, default: "none")") return currentDate } } } Here's the catch: For FixedNumberSchedule(count: 1) I get logs in console: Seq 1, 2026-10-03 10:04:33 +0000 Seq 1, none For FixedNumberSchedule(count: 2) I get infinite logs in console: Seq 2, 2026-10-03 10:04:33 +0000 Seq 2, 2026-10-03 10:04:34 +0000 Seq 2, none Seq 2, none ... Side note: the displayed result is the same for both sequences (the last valid element from second sequence is never displayed). So, If the sequence has more than a single entry to return, it actually never ends. Is this a bug? Of course, if the sequence has ended, I could keep the code as simple as possible. But the loop still troubles me, thus my initial question: Should I actually return nil or .distantFuture? BR, Krystian
0
0
45
6h
TextField vs TextEditor on iOS16
Hi, Since iOS16 TextField can take multi-line text input. Is there any reason to still use TextEditor instead of it? Can we fully replace TextEditor with TextField? Especially as we have encountered some bug in TextEditor combined with non-zero line spacing. If you input some text followed by rapidly typing a dozen of new lines, it becomes glitched. This bug is present since iOS16. BR, KK
2
0
2.5k
Oct ’23
TimelineView's custom schedule termination
Hello, How should I terminate my custom implementation of TimelineSchedule? Should I return nil or .distantFuture? Is there actual difference? Please find my sample implementation below: struct FixedNumberSchedule: TimelineSchedule { let count: Int func entries( from startDate: Date, mode: Mode ) -> Entries { Entries(startDate: startDate, count: count) } struct Entries: Sequence, IteratorProtocol { var currentDate: Date? let initialCount: Int var count: Int init(startDate: Date,count: Int) { self.currentDate = startDate self.initialCount = count self.count = count } mutating func next() -> Date? { defer { if count > 1 { currentDate?.addTimeInterval(1) count -= 1 } else { self.currentDate = nil } } print("Seq \(initialCount), \(currentDate, default: "none")") return currentDate } } } Here's the catch: For FixedNumberSchedule(count: 1) I get logs in console: Seq 1, 2026-10-03 10:04:33 +0000 Seq 1, none For FixedNumberSchedule(count: 2) I get infinite logs in console: Seq 2, 2026-10-03 10:04:33 +0000 Seq 2, 2026-10-03 10:04:34 +0000 Seq 2, none Seq 2, none ... Side note: the displayed result is the same for both sequences (the last valid element from second sequence is never displayed). So, If the sequence has more than a single entry to return, it actually never ends. Is this a bug? Of course, if the sequence has ended, I could keep the code as simple as possible. But the loop still troubles me, thus my initial question: Should I actually return nil or .distantFuture? BR, Krystian
Replies
0
Boosts
0
Views
45
Activity
6h
TextField vs TextEditor on iOS16
Hi, Since iOS16 TextField can take multi-line text input. Is there any reason to still use TextEditor instead of it? Can we fully replace TextEditor with TextField? Especially as we have encountered some bug in TextEditor combined with non-zero line spacing. If you input some text followed by rapidly typing a dozen of new lines, it becomes glitched. This bug is present since iOS16. BR, KK
Replies
2
Boosts
0
Views
2.5k
Activity
Oct ’23