我现在用AFNetworking来做异步请求,在success:^(NSURLSessionDataTask * _Nonnull task,id _Nullable responseObject)里接收放回的数据。现在有一个问题,某个页面有几个按钮,每个按钮会触发一个网络请求。如果网络不好,用户点击了多个按钮,就会触发多个网络请求,当第一个网络请求还没完成时第二个网络请求被触发,这时接收到的返回数据是最后的一个请求的,前面的不见了。有没有人遇见过这种情况?该怎么处理。请高手指点。
人生最曼妙的风景,竟是内心的淡定与从容!
If you directly use the following version of the post method, then each request is separate and there will be no "previous one is missing" situation.
- (NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(id)parameters success:(void (^)(NSURLSessionDataTask *task, id responseObject))success failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure { return [self POST:URLString parameters:parameters progress:nil success:success failure:failure]; }
Do you have the relevant cancel call?
If you directly use the following version of the post method, then each request is separate and there will be no "previous one is missing" situation.
Do you have the relevant cancel call?