我有一个带有列表通知的collectionviewcontroller。每次单击通知时,我都会将用户发送到适当的控制器。我想做的是单击行之后,我想进行API调用,而不是等待响应。这个API调用只是将这一行标记为READ,所以我不需要等待服务器的响应,也不想让用户等待。我正在使用okhttp进行API调用。这可能吗?
使您的代码请求在后台队列中像[]一样异步异步>]
DispatchQueue.global(qos: .background).async {
print("This is run on the background queue")
yourApiMethod() }
OKHttp是为Android设计的,iOS平台上没有OKHttp。您可以使用OKHttp等效库Alamofire。 Alamofire的请求代码是这样的。