【发布时间】:2016-02-25 06:11:42
【问题描述】:
我在共享扩展中遇到了 AFNetworking 的一些问题。在didSelectPost,我打电话给:
[[AuthClient sharedClient] POST: @"/v1/events"
parameters: params success: ^ (AFHTTPRequestOperation * operation, id responseObject) {
[self.extensionContext completeRequestReturningItems: nil completionHandler: nil];
}
failure: ^ (AFHTTPRequestOperation * operation, NSError * error) {
NSLog(@"error: %@", error);
[self.extensionContext cancelRequestWithError: error];
}
];
[AuthClient sharedClient] 使用单例模式获取AFHTTPSessionManager 的实例,其中NSURLSessionConfiguration 设置了背景标识符。
但是,成功或失败回调都不会被调用,它只是无限期地挂起,直到扩展被杀死。有趣的是,HTTP 请求在服务器端完成得很好;完成只是永远不会被调用。
【问题讨论】:
-
为什么不尝试新的 AFN 课程?
-
你能在调试器中停下来看看你所有的堆栈吗?看看他们中的 2 个是否试图使用同一个锁。 (或其他人的锁)
标签: ios afnetworking afnetworking-2 ios8-share-extension