Skip to content

Update to AFNetworking 3.0.0 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions BFRImageViewController/BFRImageContainerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,26 +294,24 @@ - (void)retrieveImageFromAsset {
}];
}
- (void)retrieveImageFromURL {
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:(NSURL *)self.imgSrc cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:0];
NSURL *url = (NSURL *)self.imgSrc;

AFHTTPRequestOperation *imgOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
AFHTTPSessionManager *imgOperation = [[AFHTTPSessionManager alloc] init];
imgOperation.responseSerializer = [AFImageResponseSerializer serializer];

[imgOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[imgOperation GET:url.absoluteString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
[self.progressView setProgress:downloadProgress.fractionCompleted];
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
self.imgLoaded = responseObject;
[self addImageToScrollView];
[self.progressView removeFromSuperview];
} failure:^(AFHTTPRequestOperation *operation, NSError *error){
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self.progressView removeFromSuperview];

NSLog(@"error %@", error);

[self showError];
}];

[imgOperation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
CGFloat progress = ((CGFloat)totalBytesRead)/((CGFloat)totalBytesExpectedToRead);
[self.progressView setProgress:progress];
}];

[[NSOperationQueue mainQueue] addOperation:imgOperation];
}

- (void)showError {
Expand Down
5 changes: 5 additions & 0 deletions BFRImageViewerDemo/BFRImageViewer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
2 changes: 1 addition & 1 deletion BFRImageViewerDemo/BFRImageViewer/SecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ - (void)viewDidLoad {

NSURL *url1 = [NSURL URLWithString:@"https://bufferblog-wpengine.netdna-ssl.com/wp-content/uploads/2015/10/social-media-icons-800x565.jpg"];
NSURL *url2 = [NSURL URLWithString:@"https://open.buffer.com/wp-content/uploads/2015/11/new-journey-page.png"];
NSURL *url3 = [NSURL URLWithString:@"https://bufferblog-wpengine.netdna-ssl.com/wp-content/uploads/2015/10/how-to-create-social-media-sharing-schedule-800x400.png"];
NSURL *url3 = [NSURL URLWithString:@"http://i.imgur.com/XBnuETM.jpg"];
self.imgURLs = @[url1, url2, url3];
}

Expand Down
2 changes: 1 addition & 1 deletion BFRImageViewerDemo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
target 'BFRImageViewer' do

pod 'DACircularProgress'
pod 'AFNetworking'
pod 'AFNetworking', '~> 3.0'

end

Expand Down
32 changes: 13 additions & 19 deletions BFRImageViewerDemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
PODS:
- AFNetworking (2.6.3):
- AFNetworking/NSURLConnection (= 2.6.3)
- AFNetworking/NSURLSession (= 2.6.3)
- AFNetworking/Reachability (= 2.6.3)
- AFNetworking/Security (= 2.6.3)
- AFNetworking/Serialization (= 2.6.3)
- AFNetworking/UIKit (= 2.6.3)
- AFNetworking/NSURLConnection (2.6.3):
- AFNetworking (3.0.0):
- AFNetworking/NSURLSession (= 3.0.0)
- AFNetworking/Reachability (= 3.0.0)
- AFNetworking/Security (= 3.0.0)
- AFNetworking/Serialization (= 3.0.0)
- AFNetworking/UIKit (= 3.0.0)
- AFNetworking/NSURLSession (3.0.0):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/NSURLSession (2.6.3):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (2.6.3)
- AFNetworking/Security (2.6.3)
- AFNetworking/Serialization (2.6.3)
- AFNetworking/UIKit (2.6.3):
- AFNetworking/NSURLConnection
- AFNetworking/Reachability (3.0.0)
- AFNetworking/Security (3.0.0)
- AFNetworking/Serialization (3.0.0)
- AFNetworking/UIKit (3.0.0):
- AFNetworking/NSURLSession
- DACircularProgress (2.3.1)

DEPENDENCIES:
- AFNetworking
- AFNetworking (~> 3.0)
- DACircularProgress

SPEC CHECKSUMS:
AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60
AFNetworking: 932ff751f9d6fb1dad0b3af58b7e3ffba0a4e7fd
DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71

COCOAPODS: 0.39.0

This file was deleted.

This file was deleted.

Loading