Skip to content

Commit 8f8ba70

Browse files
added foreach
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
1 parent 8861239 commit 8f8ba70

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Sources/NextcloudKit/Utils/SynchronizedNKSessionArray.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public final class SynchronizedNKSessionArray: @unchecked Sendable {
4444
queue.sync { array }
4545
}
4646

47+
/// Calls the given closure on each session in the array, in order.
48+
/// - Parameter body: A closure that takes a `NKSession` as a parameter.
49+
public func forEach(_ body: (NKSession) -> Void) {
50+
queue.sync {
51+
array.forEach(body)
52+
}
53+
}
54+
4755
/// Returns the first session matching a given account string.
4856
/// - Parameter account: The account identifier string to match.
4957
/// - Returns: A `NKSession` instance if found, otherwise `nil`.

0 commit comments

Comments
 (0)