简体   繁体   中英

AFNetworking 3 - How initialize NSProgress

I'm using AFNetworking 3.1.0 and GET:parameters:success:failure is deprecated so I want to use GET:parameters:progress:success:failure which is not.

- (NSURLSessionDataTask *)GET:(NSString *)URLString
                   parameters:(id)parameters
                     progress:(void (^)(NSProgress * _Nonnull))downloadProgress
                      success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
                      failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure

According to docs progress should be not null so I wonder how can I NSProgress object and make a simple GET request to a REST API.

You don't have to create any progress object for that. But you will get the progress of your downloading inside this block. So you can calculate download progress and display it as per your requirement by creating progress indicator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM