0
這是我的代碼,請檢查我錯了。在請求後將不會調用成功或失敗的方法。請幫助我。Afnetworking代理方法沒有被調用
-(void)downLoadTask {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* mediaKey = [NSString stringWithFormat:@"%@/Sample.m4v", documentsDirectory];
NSLog(@"%@",mediaKey);
NSString *strPath = @"/sites/default/files/media/Master_Talara1_9.mp4";
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:[self.HTTPClient requestWithMethod:@"GET" path:strPath parameters:nil]];
operation.downloadSpeedMeasure.active = YES;
[operation setShouldExecuteAsBackgroundTaskWithExpirationHandler:^{
NSLog(@"time out");
// Clean up anything that needs to be handled if the request times out
// It may be useful to initially check whether the operation finished or was cancelled
}];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:mediaKey append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success");
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@",error);
}];
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
humanReadableRemaingTime = [operation.downloadSpeedMeasure humanReadableRemainingTimeOfTotalSize:totalBytesExpectedToRead numberOfCompletedBytes:bytesRead];
NSLog(@"Time is human read %@",humanReadableRemaingTime);
}];
}
是否有被implemnted任何幾種方法得到調用AFNetWorking委託方法
你的操作添加一些隊列來運行呢? – kirander