Search code examples
iosobjective-cafnetworking-3

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.


Solution

  • 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.