-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes
More file actions
66 lines (49 loc) · 1.5 KB
/
notes
File metadata and controls
66 lines (49 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## Testing Identifiers
enum TestingIDs {
enum ModuleName {
static let name = "string"
static func item(for: someItem) -> String {
"string \(someItem.someProperty)"
}
}
}
In a source file
let testID = TestingIDs.ModuleName.self
and use the above like
.accessibilityIdentifier(testID.name)
## Given the WCSession API function
```swift
func sendMessage(
_ message: [String : Any],
replyHandler: (([String : Any]) -> Void)?,
errorHandler: ((any Error) -> Void)? = nil
)
```
I'd have expected this to work where session is WCSession.default
```swift
@MainActor
final class Something: NSObject, WCSessionDelegate {
// ...
// delegate functions are marked as nonisolated
func sendSomeData(someValue: SomeType) {
// build a plist using someValue
session.sendMessage(["Key": someValuePlist]) { response in
// process the response here
} errorHandler: { error in
// process any error here
}
}
}
```
A watch app that does this crashes in _dispatch_assert_queue_fail
with comments about a block being run on the wrong queue. Swift 6
mode.
However, if I take the code in the closure and move it to a function
```swift
func responseHandler(response: [String: Any]) {
// process the response here
}
```
The app works as expected. I assume the app would also crash if the
error handling closure was invoked so made it a separate function, too.
Should I have expected this?