2
AFNetworking 일괄 요청을 사용하여 서버에 업로드하려는 이미지 배열이 있습니다. 여기에 내 코드가, 나는 오류가있어 내가 여기AFNetworking 2를 사용하여 이미지 배열 업로드 일괄 요청
-(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
사람이 도울 수
오류 왜 모르겠어요? 감사합니다
'imageArray'는 분명히 URL의 배열입니까? 어딘가에 누군가 문자열을 기대하지만 이미지를 얻고 있습니다. 기반 : UIImage에서 호출되는'lastPathComponent' (NSString 메서드). – Logan
당신이 옳았어요 ... URL 배열이 아니므로 이미지를 반영하도록 코드를 변경했는데 효과가있었습니다 .. 대답을하면 받아 들일 것입니다 .. 감사합니다 – vinylDeveloper
다행히 해결했습니다! – Logan