afu

AFURLConnectionByteSpeedMeasure

Extends AFNetworking with the ability to measure connection speed and estimate completion time.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

149

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

1

License

MIT

Categories

Readme

AFURLConnectionByteSpeedMeasure

AFURLConnectionByteSpeedMeasure is a drop in extension for AFNetworking to measure download and upload speed of an AFURLConnectionOperation and estimate completion times.

Usage

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://download.thinkbroadband.com/1GB.zip"]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.downloadSpeedMeasure.active = YES;

// to avoid a retain cycle one has to pass a weak reference to operation into the progress block.
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
    double speedInBytesPerSecond = operation.downloadSpeedMeasure.speed;
    NSString *humanReadableSpeed = operation.downloadSpeedMeasure.humanReadableSpeed;

    NSTimeInterval remainingTimeInSeconds = [operation.downloadSpeedMeasure remainingTimeOfTotalSize:totalBytesExpectedToRead numberOfCompletedBytes:totalBytesRead];
    NSString *humanReadableRemaingTime = [operation.downloadSpeedMeasure humanReadableRemainingTimeOfTotalSize:totalBytesExpectedToRead numberOfCompletedBytes:totalBytesRead];
}];

Lincense

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100