Created
April 8, 2025 21:20
-
-
Save siracusa/68e3b56cd9b32c5f42351f9b851b54c6 to your computer and use it in GitHub Desktop.
A Logger call with an interpolated value stops this code from compiling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import OSLog | |
import Network | |
import Foundation | |
let logger = Logger(subsystem: "com.example.demo", category: "Default") | |
let connection = NWConnection(host: NWEndpoint.Host("time.apple.com"), port: 123, using: .udp) | |
// The line below fails to compile: Type of expression is ambiguous without a type annotation | |
connection.stateUpdateHandler = { state in | |
// Comment out this logger call (or remove the interpolated | |
// "state" variable) to fix the compilation error. | |
logger.debug("stateUpdateHandler: \(state, privacy: .public)") | |
switch state { | |
case .ready: | |
print("ready") | |
default: | |
break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment