You'll only deal with URLSession class that has two main methods (request / Download). (UrlSession is a singleton)
- (void)request:(NSString *)URL method:(NSString *)method parameters:(NSDictionary *)parameters completion:( void (^)(NSDictionary *response, NSError *error))completionHandler
URL - NSString: request URL
method - NSString: Request Method (Get/Post/Put)
parameters - NSDictionary: request parameters
Completion - Block: fires when request completed to return data to the enqueuer
URLSession *urlSession = [URLSession sharedNetworkSession];
[urlSession request:@"< Your URL >" method:POST_METHOD_TYPE parameters:@{@"key1" : @"value1",@"key2" : @"value2"} completion:^(NSDictionary *response, NSError *error){
// Your Data Dictionary
}];
- (void)Download:(NSString *)URL method:(NSString *)method parameters:(NSDictionary *)parameters;
URL - NSString: request URL
method - NSString: Request Method (Download)
parameters - NSDictionary: request parameters
To implement this method and get current download progress and be notified when download completed, You should implement the protocol URLSessionDownloadDelegate
URLSession *urlSession = [URLSession sharedNetworkSession];
urlSession.delegate = self;
[urlSession Download:@"http://upload.wikimedia.org/wikipedia/commons/7/7f/Williams_River-27527.jpg" method:DOWNLOAD_METHOD_TYPE parameters:nil];
To use InstaImageView, you can use it directly in your story board by dragging UIImageView and change class to InstaImageView. In your view controller, whenever you've the image URL then call download method -(void)setImageWithURL:(NSString *)url defaultImage:(UIImage *)defaultImage;
URL - NSString: request URL
defaultImage - UIImage: default image to be displayed until downloading the image
[_instaImgView setImageWithURL:@"http://upload.wikimedia.org/wikipedia/commons/7/7f/Williams_River-27527.jpg" defaultImage:[UIImage imageNamed:@"<YOUR_DEFAULT_IMAGE>"]];
InstaNetworking is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'InstaNetworking'
Mahmoud Amer, mahmoud.amer.m@gmail.com
InstaNetworking is available under the MIT license. See the LICENSE file for more info.