mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix(skills): improve code examples in iOS 26 skills
- Add do-catch error handling to SwiftUI streaming example in foundation-models-on-device - Add Auto Layout constraints to UIKit glass effect example in liquid-glass-design - Promote build settings prerequisite from code comment to visible blockquote warning in swift-concurrency-6-2
This commit is contained in:
@@ -178,6 +178,7 @@ for try await partial in stream {
|
||||
|
||||
```swift
|
||||
@State private var partialResult: TripIdeas.PartiallyGenerated?
|
||||
@State private var errorMessage: String?
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
@@ -185,11 +186,18 @@ var body: some View {
|
||||
Text(idea)
|
||||
}
|
||||
}
|
||||
.overlay {
|
||||
if let errorMessage { Text(errorMessage).foregroundStyle(.red) }
|
||||
}
|
||||
.task {
|
||||
do {
|
||||
let stream = session.streamResponse(to: prompt, generating: TripIdeas.self)
|
||||
for try await partial in stream {
|
||||
partialResult = partial
|
||||
}
|
||||
} catch {
|
||||
errorMessage = error.localizedDescription
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -138,13 +138,27 @@ glassEffect.tintColor = UIColor.systemBlue.withAlphaComponent(0.3)
|
||||
glassEffect.isInteractive = true
|
||||
|
||||
let visualEffectView = UIVisualEffectView(effect: glassEffect)
|
||||
visualEffectView.translatesAutoresizingMaskIntoConstraints = false
|
||||
visualEffectView.layer.cornerRadius = 20
|
||||
visualEffectView.clipsToBounds = true
|
||||
|
||||
view.addSubview(visualEffectView)
|
||||
NSLayoutConstraint.activate([
|
||||
visualEffectView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
visualEffectView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||
visualEffectView.widthAnchor.constraint(equalToConstant: 200),
|
||||
visualEffectView.heightAnchor.constraint(equalToConstant: 120)
|
||||
])
|
||||
|
||||
// Add content to contentView
|
||||
let label = UILabel()
|
||||
label.text = "Liquid Glass"
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
visualEffectView.contentView.addSubview(label)
|
||||
NSLayoutConstraint.activate([
|
||||
label.centerXAnchor.constraint(equalTo: visualEffectView.contentView.centerXAnchor),
|
||||
label.centerYAnchor.constraint(equalTo: visualEffectView.contentView.centerYAnchor)
|
||||
])
|
||||
```
|
||||
|
||||
### UIGlassContainerEffect for Multiple Elements
|
||||
|
||||
@@ -136,10 +136,9 @@ This mode is opt-in and recommended for apps, scripts, and other executable targ
|
||||
|
||||
When you need actual parallelism, explicitly offload with `@concurrent`:
|
||||
|
||||
> **Important:** This example requires Approachable Concurrency build settings — SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). With these enabled, `extractSticker` stays on the caller's actor, making mutable state access safe. **Without these settings, this code has a data race** — the compiler will flag it.
|
||||
|
||||
```swift
|
||||
// Assumes Approachable Concurrency build settings are enabled:
|
||||
// SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault).
|
||||
// Safe mutation of cachedStickers via await depends on these compiler options.
|
||||
nonisolated final class PhotoProcessor {
|
||||
private var cachedStickers: [String: Sticker] = [:]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user