0
我无法弄清楚为什么Xcode的静态分析器给我警告“'nil'从预期返回非null的方法返回值”。方法是:在dispatch_sync中初始化一个对象的方法由静态分析器标记为返回零的块
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
fromFile:(NSURL *)fileURL
progress:(NSProgress * __autoreleasing *)progress
completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler {
__block NSURLSessionUploadTask *uploadTask = nil;
dispatch_sync(url_session_manager_creation_queue(), ^{
uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
});
if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) {
for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) {
uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
}
}
[self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler];
return uploadTask; // nil returned from a method that is expected to return a non-null value
}
分析仪状态:nil从预期返回非空值的方法返回 –
该方法在'.h'文件中如何声明?它是否重写超类方法? –
'self.session'是否可以空? – PHD