Partial application forwarder for assisted rehab assistant from @callee_unowned

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
+4
source share
1 answer

You are probably afnetworking.get(someURL, parameters: nil, successHandler:calling successHandlermultiple times inside .

The second call optionalHandler()disconnects your application

0
source

Source: https://habr.com/ru/post/1676565/


All Articles