小编mde*_*les的帖子

AFNetworking 2使用AFHTTPRequestOperation进行身份验证

我想通过批量操作使用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)

非常感谢你

ios afnetworking-2

9
推荐指数
1
解决办法
5156
查看次数

如何在 git diff 输出中正确显示重音符号

当我运行 git diff 命令时,文件列表中所有带有重音符号的文件显示效果不佳:

\n\n
 git diff --name-status xxxx yyyyyy\n
Run Code Online (Sandbox Code Playgroud)\n\n

返回

\n\n
M       "\\303\\251\\303\\251.txt"\n
Run Code Online (Sandbox Code Playgroud)\n\n

我怎样才能保留口音来拥有这个?:

\n\n
M       "\xc3\xa9\xc3\xa9.txt"\n
Run Code Online (Sandbox Code Playgroud)\n\n

谢谢

\n\n

编辑:我指定该文件以 UTF-8 编码,并尝试使用 OSX 中的 git 2.3.2 和 Ubuntu 中的 git 1.9.1

\n

git

3
推荐指数
1
解决办法
637
查看次数

标签 统计

afnetworking-2 ×1

git ×1

ios ×1