我有一系列图像,我尝试使用AFNetworking批量请求上传到服务器。这是我的代码,我收到了错误,我不知道为什么
-(void)imageUploader {
NSArray *imageArray = _listing.productImageArray;
imageCounter = 1;
NSString * ts = [NSString stringWithFormat:@"%f",[[NSDate new] timeIntervalSince1970] * 1000];
NSMutableArray *mutableOperations = [NSMutableArray array];
for (NSURL *fileURL in imageArray) {
imagesUploaded = 0;
NSString *counter = [NSString stringWithFormat:@"%i", imageCounter];
NSURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"https://myayla.com/bl/saveProductImages.php" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:fileURL name:@"images[]" error:nil];
} error:nil];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[mutableOperations addObject:operation];
}
NSArray *operations = [AFURLConnectionOperation batchOfRequestOperations:mutableOperations progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {
NSLog(@"%lu of %lu complete", numberOfFinishedOperations, totalNumberOfOperations);
} completionBlock:^(NSArray *operations) {
NSLog(@"All operations in batch complete");
}];
[[NSOperationQueue mainQueue] addOperations:operations waitUntilFinished:NO];
这是错误
'NSInvalidArgumentException', reason: '-[UIImage lastPathComponent]: unrecognized selector sent to instance
任何人都可以帮忙吗?感谢
答案 0 :(得分:0)
图像阵列肯定是一个URL数组吗?在某个地方,有人期待一个字符串,但他们正在获得一个图像。基于:在UIImage上调用lastPathComponent
(NSString方法)。