diff --git a/skills/ios-application-dev/references/swift-coding-standards.md b/skills/ios-application-dev/references/swift-coding-standards.md index bf70237..b9408b8 100644 --- a/skills/ios-application-dev/references/swift-coding-standards.md +++ b/skills/ios-application-dev/references/swift-coding-standards.md @@ -157,9 +157,18 @@ extension Drawable { extension Collection { func chunked(into size: Int) -> [[Element]] { - stride(from: 0, to: count, by: size).map { - Array(self[$0.. 0 else { return [] } + + var result: [[Element]] = [] + var i = startIndex + + while i != endIndex { + let j = index(i, offsetBy: size, limitedBy: endIndex) ?? endIndex + result.append(Array(self[i..(_ operation: () throws -> T) rethrows -> T { **Impact:** CRITICAL +Use actor isolation and `Sendable` to prevent data races across concurrency domains. + ### 7.1 Async Functions ```swift @@ -715,13 +730,14 @@ UIView.animate(withDuration: 0.3) { - [ ] No implicitly unwrapped optionals (`!`) in data models ### Memory -- [ ] Closures use `[weak self]` when capturing self in escaping closures +- [ ] Escaping closures capture `self` intentionally; use `[weak self]` or `[unowned self]` to avoid retain cycles when needed - [ ] Delegate properties are `weak` - [ ] No retain cycles between objects ### Concurrency - [ ] Async functions used instead of completion handlers -- [ ] Actors protect shared mutable state +- [ ] Mutable state shared across concurrency domains is isolated, often with actors +- [ ] Types crossing concurrency domains use `Sendable` when appropriate - [ ] UI updates on `@MainActor` - [ ] Task cancellation checked in long operations