I have the following Swift function:
func refresh(optionalHandler: @escaping (() -> Void) = {}) {
afnetworking.get(someURL, parameters: nil, successHandler: {
(task: URLSessionDataTask, object: Any) in
print(task)
optionalHandler() // This crashes with EXC_BAD_ACCESS
})
}
Not sure what is going on here ... full error:
optionalHandler () -> () 0x000000010018baac MyApp`partial apply forwarder for reabstraction thunk helper from @callee_unowned @convention(block) () -> () to @callee_owned () -> () at MyViewController.swift
7ball source
share