Relative Content

Tag Archive for swiftclosures

closure is giving me this error “Sending ‘onResultFetched’ risks causing data races”

func main2() { studentResult(rollNo: “1234”, onResultFetched: { isPassed in print(isPassed ? “You are pass” : “You are fail”) }) } We use @escaping when we want to wait for the something so it tells the function to wait and won’t destroy itself until we get response func studentResult(rollNo: String, onResultFetched: @escaping (Bool) -> Void) { […]