我想通过批量操作使用AFNetworking.我想下载3个json文件.
如何使用AFHTTPRequestOperation添加基本身份验证?
NSMutableArray *mutableOperations = [NSMutableArray array];
for (NSString *fileURL in filesToDownload) {
NSURLRequest *request = [NSURLRequest
requestWithURL:[NSURL URLWithString:fileURL]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation
, id responseObject) {
NSLog(@"success: %@", operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", operation.responseString);
}];
[mutableOperations addObject:operation];
}
NSArray *operations = [AFURLConnectionOperation batchOfRequestOperations:mutableOperations
progressBlock:^(NSUInteger numberOfFinishedOperations
, NSUInteger totalNumberOfOperations) {
NSLog(@"%d of %d complete", numberOfFinishedOperations, totalNumberOfOperations);
} completionBlock:^(NSArray *operations) {
NSLog(@"All operations in batch complete");
}];
[[NSOperationQueue mainQueue] addOperations:operations waitUntilFinished:NO];
Run Code Online (Sandbox Code Playgroud)
非常感谢你
当我运行 git diff 命令时,文件列表中所有带有重音符号的文件显示效果不佳:
\n\n git diff --name-status xxxx yyyyyy\nRun Code Online (Sandbox Code Playgroud)\n\n返回
\n\nM "\\303\\251\\303\\251.txt"\nRun Code Online (Sandbox Code Playgroud)\n\n我怎样才能保留口音来拥有这个?:
\n\nM "\xc3\xa9\xc3\xa9.txt"\nRun Code Online (Sandbox Code Playgroud)\n\n谢谢
\n\n编辑:我指定该文件以 UTF-8 编码,并尝试使用 OSX 中的 git 2.3.2 和 Ubuntu 中的 git 1.9.1
\n