小编Joh*_*ohn的帖子

AFNetworking - 通过UIProgressView下载多个文件+监控

我正在尝试将我的代码从ASIHTTPRequest更改为AFNetworking.目前我想选择10-15个不同的HTTP URL(文件)并将它们下载到文档文件夹.

使用ASIHTTPRequest非常简单

[myQueue setDownloadProgressDelegate:myUIProgressView];
Run Code Online (Sandbox Code Playgroud)

在AFNetworking中我无法弄清楚如何做到这一点.我有以下代码下载文件,存储它们并在文件成功下载时通知,但我无法为此队列创建总大小的进度条.

for (i=0; i<3; i++) {

    NSString *urlpath = [NSString stringWithFormat:@"http://www.domain.com/file.zip"];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlpath]];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"testFile%i.zip",i]];
    operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"Successfully downloaded file to %@", path);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];

    [operation setDownloadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
        NSLog(@"Sent %d of %d …
Run Code Online (Sandbox Code Playgroud)

iphone asihttprequest ios afnetworking

11
推荐指数
1
解决办法
1万
查看次数

带有返回2个值的函数的SQL查询

如何从查询中的SQL Server中的用户定义函数返回多个值(例如,数字和字符串)?

例如 select col1, dbo.function1(col2) from table

结果是

Col1 |        Col2       |         Col3
-----+-------------------+---------------------
x    | Num from function | String from function
Run Code Online (Sandbox Code Playgroud)

我不想调用该函数2次,因为我使用了一些复杂的代码而且我不想执行它两次.只是在Return中取得最后2个结果

sql sql-server function

2
推荐指数
2
解决办法
5万
查看次数

标签 统计

afnetworking ×1

asihttprequest ×1

function ×1

ios ×1

iphone ×1

sql ×1

sql-server ×1