{"id":1632,"url":"https://github.com/skywite/SWNetworking","last_synced_at":"2025-08-02T04:32:10.107Z","repository":{"id":34090179,"uuid":"37913916","full_name":"skywite/SWNetworking","owner":"skywite","description":null,"archived":false,"fork":false,"pushed_at":"2017-09-21T07:44:19.000Z","size":175,"stargazers_count":25,"open_issues_count":0,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-08T21:02:47.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skywite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-23T11:03:56.000Z","updated_at":"2024-01-18T01:37:10.000Z","dependencies_parsed_at":"2022-07-18T01:11:14.226Z","dependency_job_id":null,"html_url":"https://github.com/skywite/SWNetworking","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywite%2FSWNetworking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywite%2FSWNetworking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywite%2FSWNetworking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skywite%2FSWNetworking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skywite","download_url":"https://codeload.github.com/skywite/SWNetworking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228439068,"owners_count":17920017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:51.875Z","updated_at":"2024-12-06T08:31:22.874Z","avatar_url":"https://github.com/skywite.png","language":"Objective-C","funding_links":[],"categories":["Networking"],"sub_categories":["Video","Other free courses"],"readme":"# \u003cp align=\"center\" style='color:#30a1f3' \u003eSWNetworking\u003c/p\u003e\n\n\u003cp align=\"center\" \u003e\n  \u003cimg src=\"http://skywite.com/wp-content/uploads/2015/05/skywite.png\" alt=\"SWNetworking\" title=“SkyWite”\u003e\n\u003c/p\u003e\n\n\n[![Build Status](https://travis-ci.org/skywite/SWNetworking.svg?branch=master)](https://travis-ci.org/skywite/SWNetworking)\n[![Version](https://img.shields.io/cocoapods/v/SWNetworking.svg?style=flat)](http://cocoapods.org/pods/SWNetworking)\n[![License](https://img.shields.io/cocoapods/l/SWNetworking.svg?style=flat)](http://cocoapods.org/pods/SWNetworking)\n[![Platform](https://img.shields.io/cocoapods/p/SWNetworking.svg?style=flat)](http://cocoapods.org/pods/SWNetworking)\n[![Analytics](https://ga-beacon.appspot.com/UA-69386051-1/SWNetworking/README?pixel)](https://github.com/igrigorik/ga-beacon)\n[![Twitter](https://img.shields.io/badge/twitter-@SWframeworks-blue.svg?style=flat)](http://twitter.com/SWframeworks)\n\n\n\nSkyWite is an open-source and highly versatile multi-purpose frameworks. Clean code and sleek features make SkyWite an ideal choice. Powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.\n\nAchieve your deadlines by using SkyWite. You will save Hundred hours. \n\nStart development using Skywite. Definitely you will be happy....! yeah..\n\n\n# Requirements\n\nYou need to add \"SystemConfiguration\" framework into your project before implement this.\n\n\n#How to apply to Xcode project\n\n### Downloading Source Code\n - [Download SWNetworking](https://github.com/skywite/SWNetworking/archive/master.zip) from gitHub\n - Add required frameworks\n - import \"SWNetworking.h\" to your source code file\n \n### Using CocoaPods\n\nSWNetworking is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"SWNetworking\"\n```\n\nIf you are new to CocoaPods, please go to [Wiki](https://github.com/skywite/SWNetworking/wiki/CocoaPods-in-to-Xcode-Project) page.\n\n- Read the [SWNetworking 1.0 Migration Guide](https://github.com//skywite/SWNetworking/wiki/SWNetworking-1.0-Migration-Guide) for an overview of the architectural changes from 0.9.3\n\n### Communication\n\n- If you **need any help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/swnetworking). (Tag 'swnetworking') or you can send a mail with details ( we will provide fast feedback )\n- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/SWNetworking).\n- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue or you can contribute.\n- If you **have a feature request**, send a request mail we will add as soon as possible.\n- If you **want to contribute**, submit a pull request.\n\n#Architecture\n\n\n* `SWRequest`\n - `SWRequest`\n    - `SWGETRequest`\n    - `SWPOSTRequest`\n        - `SWMultiPartRequest` \n    - `SWPUTRequest`\n    - `SWPATCHRequest`\n    - `SWDELETERequest`\n    - `SWHEADRequest`\n - `SWOfflineRequestManger`\n* `ResponseType`\n    - `SWResponseDataType`\n        - `SWResponseJSONDataType`\n        - `SWResponseXMLDataType`\n        - `SWResponseStringDataType`\n        - `SWResponseUIImageType`\n    - `SWRequestDataType`\n        - `SWRequestFormData`\n        - `SWRequestMulitFormData`\n        - `SWRequestJSONData`\n* `Reachability`\n    - `SWReachability`\n* `File`\n    - `SWMedia`\n* `UIKit+SWNetworking`\n    - `UIImageView+SWNetworking`\n    - `UIProgressView+SWNetworking`\n# How to Use\n\n## Use HTTP Request will be `NSURLSession`\nALL Requests will be NSURLSession. Session will add in to `NSOperationQueue` . Request creation , response serialization, network reachability handing and offline request as well.\n\n### `GET` Request\n```objective-c\n\tSWGETRequest *getRequest = [[SWGETRequest alloc]init];\n    [getRequest startDataTaskWithURL:@\"http://127.0.0.1:3000\" parameters:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n   \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n    \n    }];\n```\nIf you want send parameters you have two options\n\n```objective-c\n    SWGETRequest *getRequest = [[SWGETRequest alloc]init];\n    getRequest.responseDataType = [SWResponseJSONDataType type];\n    [getRequest startDataTaskWithURL:@\"http://127.0.0.1:3000\" parameters:@\"name=this is name\u0026address=your address\"  parentView:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n\n    }];\n```\nIf you want to encdoe parameters and values you need to pass `NSDictionary` object with keys/values.\n\n```objective-c\n\tSWGETRequest *getRequest = [[SWGETRequest alloc]init];\n    getRequest.responseDataType = [SWResponseJSONDataType type];\n    [getRequest startDataTaskWithURL:@\"http://127.0.0.1:3000\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n\n    }];\n```\n\nWe are recommend to use second option because if you have `\u0026` sign with parameter or value it will break sending values.\n\n###  `GET` with Response type \nAvailable as response types\n`SWResponseJSONDataType`, `SWResponseJSONDataType`, `SWResponseXMLDataType`,` SWResponseStringDataType`,`SWResponseUIImageType`  \nYou need set `responseDataType`.\n\n```objective-c\n// this response will be JSON\n  \tSWGETRequest *getRequest = [[SWGETRequest alloc]init];\n    getRequest.responseDataType = [SWResponseJSONDataType type];\n    [getRequest startDataTaskWithURL:@\"http://127.0.0.1:3000\" parameters:nil parentView:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n    \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n\n    }];\n```\n### `GET` with loading indicator\nIf you set your parent view to method, loading indicator will be displayed. \n```objective-c\n    SWGETRequest *getRequest = [[SWGETRequest alloc]init];\n    getRequest.responseDataType = [SWResponseJSONDataType type];\n    [getRequest startDataTaskWithURL:@\"http://127.0.0.1:3000\" parameters:nil parentView:self.view success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n    \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n\n    }];\n```\n\nIf you want custom loading view you need to add new `nib` file to your project and name it as 'sw_loadingView'. It will be displayed on the screen.\n### Cache Response\nIf you want to access cached data on the response. You need to use relevant method that include cache block\n```objective-c\n \tSWGETRequest *getRequest = [[SWGETRequest alloc]init];\n    getRequest.responseDataType = [SWResponseJSONDataType type];\n    [getRequest startDataTaskWithURL:@\"http://127.0.0.1:3000\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n    \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n\n    }];\n```\n### `POST` request (simple)\nCache, Loading view available for the on the relevant method. Please check available methods\n```objective-c\n\tSWPOSTRequest *postRequest = [[SWPOSTRequest alloc]init];\n    postRequest.responseDataType = [SWResponseJSONDataType type];\n    \n    [postRequest startDataTaskWithURL:@\"http://127.0.0.1:3000/drivers\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"} parentView:nil cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];\n```\n\n### `POST` multipart request\nIt is really easy.\n```objective-c\n \tSWPOSTRequest *postRequest = [[SWPOSTRequest alloc]init];\n    postRequest.responseDataType = [SWResponseJSONDataType type];\n    \n    //need to crate files array to upload\n    \n    UIImage *image = [UIImage imageNamed:@\"skywite\"];\n    NSData *imageData = UIImagePNGRepresentation(image);\n    SWMedia *file1 = [[SWMedia alloc]initWithFileName:@\"imagefile.png\" key:@\"image\" data:imageData];\n    \n    //create with custom mine type one\n    \n    SWMedia *file2 = [[SWMedia alloc]initWithFileName:@\"image.jpg\" key:@\"image2\" mineType:@\"image/jpeg\" data:imageData];\n    \n    //create an array with files\n    \n    NSArray *fileArray = @[file1, file2];\n    \n    [postRequest startUploadTaskWithURL:@\"http://127.0.0.1:3000/drivers\" files:fileArray parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"} parentView:nil\n    cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionUploadTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];\n```\n### `PUT` simple request\n```objective-c\n\tSWPUTRequest *putRequest = [[SWPUTRequest alloc]init];\n    putRequest.responseDataType = [SWResponseXMLDataType type];\n    \n    [putRequest startDataTaskWithURL:@\"http://127.0.0.1:3000/drivers\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];}\n```\n### `PATCH` simple request\n```objective-c\n    SWPATCHRequest *patchRequest = [[SWPATCHRequest alloc]init];\n    patchRequest.responseDataType = [SWResponseXMLDataType type];\n    \n    [patchRequest startDataTaskWithURL:@\"http://127.0.0.1:3000/drivers\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:nil success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];\n\n```\n### `DELETE` simple request\n```objective-c\n \tSWDELETERequest *deleteRequest = [[SWDELETERequest alloc]init];\n    deleteRequest.responseDataType = [SWResponseXMLDataType type];\n    \n    [deleteRequest startDataTaskWithURL:@\"http://127.0.0.1:3000/drivers\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:nil cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];\n```\n\n### `HEAD` simple request\n```objective-c\n\tSWHEADRequest *headRequest = [[SWHEADRequest alloc]init];\n    headRequest.responseDataType = [SWResponseXMLDataType type];\n    \n    [headRequest startDataTaskWithURL:@\"http://127.0.0.1:3000/drivers\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:nil cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];}\n```\n## Features\nall the following features averrable on all the request types. \neg : If you want to access you need to call relevant method that include cache block \n\n### Custom headers\nIf you want to add custom headers you can set to accessing request object.\n```objective-c\n\tSWPOSTRequest *postRequest = [[SWPOSTRequest alloc]init];\n    \n    [postRequest.request setValue:@\"application/x-www-form-urlencoded\" forHTTPHeaderField:@\"Content-Type\"];\n    postRequest.responseDataType = [SWResponseJSONDataType type];\n    \n    [postRequest startDataTaskWithURL:@\"your URL String\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:self.view cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        \n        NSLog(@\"%@\", responseObject);\n        \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        \n    }];\n```\n\n### Custom time out\nIf you want to change request timeout , you have to change property call `timeOut`.\n```objective-c\n  \tSWPOSTRequest *postRequest = [[SWPOSTRequest alloc]init];\n    [postRequest setTimeOut:120];\n    postRequest.responseDataType = [SWResponseJSONDataType type];\n    \n    [postRequest startDataTaskWithURL:@\"your URL String\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:self.view cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        \n        NSLog(@\"%@\", responseObject);\n        \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        \n    }];\n```\n \n### Response Encoding\nYou need to sent object type for the `responseDataType` on all your requests.\n\n```objective-c\n \t//JSON\n    SWPOSTRequest *postRequest = [[SWPOSTRequest alloc]init];\n    postRequest.responseDataType = [SWResponseJSONDataType type];\n    \n    [postRequest startDataTaskWithURL:@\"your URL String\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:self.view cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        \n        NSLog(@\"%@\", responseObject);\n        \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        \n    }];\n    \n    \n    //XML\n    SWPOSTRequest *postRequestXML = [[SWPOSTRequest alloc]init];\n    postRequestXML.responseDataType = [SWResponseJSONDataType type];\n    \n    [postRequestXML startDataTaskWithURL:@\"your URL String\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:self.view cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        \n        NSLog(@\"%@\", responseObject);\n        \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        \n    }];\n    \n    //String\n    SWPOSTRequest *postRequestString = [[SWPOSTRequest alloc]init];\n    postRequestString.responseDataType = [SWResponseStringDataType type];\n    \n    [postRequestString startDataTaskWithURL:@\"your URL String\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:self.view cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        \n        NSLog(@\"%@\", responseObject);\n        \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        \n    }];\n    \n    //String\n    SWGETRequest *getRequestImage = [[SWGETRequest alloc]init];\n    getRequestImage.responseDataType = [SWResponseUIImageType type];\n    \n    [getRequestImage startDataTaskWithURL:@\"your URL String\" parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"}  parentView:self.view cachedData:^(NSCachedURLResponse *response, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } success:^(NSURLSessionDataTask *uploadTask, id responseObject) {\n        \n        NSLog(@\"%@\", responseObject);\n        \n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        \n    }];\n\n```\n\n### `UIImageView` with `SWNetworking`\nNo need to download image and set to `UIImageView` anymore. You can set url to `UIImageView`. \n\n```objective-c\n\t// Please use only one method . you can see 4 methods :)\n    \n    // from url\n    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];\n    [imageView loadWithURLString:@\"image url\"];\n    \n    \n    //if you want to load image cache and then load download you can use following method\n    [imageView loadWithURLString:@\"image url\" loadFromCacheFirst:YES];\n    \n    //If you want to get complete event\n    [imageView loadWithURLString:@\"image url\" complete:^(UIImage *image) {\n        //you can assing your image to your object here.\n    }];\n    \n    //if you want cache and image handle\n    [imageView loadWithURLString:@\"image url\" loadFromCacheFirst:YES complete:^(UIImage *image) {\n        \n    }];\n```\n\n### Check Reachability\nNew Reachability class to support block when change network status\navailable Status\n\n`SWNetworkReachabilityStatusNotReachable`\n`SWNetworkReachabilityStatusReachableViaWWAN`\n`SWNetworkReachabilityStatusReachableViaWiFi`\n\n```objective-c\n\tif ([SWReachability getCurrentNetworkStatus] == SWNetworkingReachabilityStatusNotReachable) {\n        //connection not available.\n    }\n    \n    //if you want to get status change notification\n    \n    [SWReachability checkCurrentStatus:^(SWNetworkingReachabilityStatus currentStatus) {\n        //current status when call method\n    } statusChange:^(SWNetworkingReachabilityStatus changedStatus) {\n        //every time when change status\n    }];\n\n```\n\n### Upload progress With Request\n\n```objective-c\n    SWPOSTRequest *postRequest = [[SWPOSTRequest alloc]init];\n    postRequest.responseDataType = [SWResponseJSONDataType type];\n    \n    //need to crate files array to upload\n    \n    UIImage *image = [UIImage imageNamed:@\"skywite\"];\n    NSData *imageData = UIImagePNGRepresentation(image);\n    SWMedia *file1 = [[SWMedia alloc]initWithFileName:@\"imagefile.png\" key:@\"image\" data:imageData];\n    \n    \n    //create with custom mine type one\n    \n    SWMedia *file2 = [[SWMedia alloc]initWithFileName:@\"image.jpg\" key:@\"image2\" mineType:@\"image/jpeg\" data:imageData];\n    \n    //create an array with files\n    \n    NSArray *fileArray = @[file1, file2];\n    \n    [postRequest startUploadTaskWithURL:@\"http://127.0.0.1:3000/drivers\" files:fileArray parameters:@{@\"name\": @\"this is name\", @\"address\": @\"your address\"} parentView:nil  success:^(NSURLSessionUploadTask *uploadTask, id responseObject) {\n        NSLog(@\"%@\", responseObject);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"%@\", error);\n    }];\n    [postRequest setUploadProgressBlock:^(long long bytesWritten, long long totalBytesExpectedToWrite) {\n        NSLog(@\"bytesWritten =\u003e %lld and totalBytesExpectedToWrite = %lld\", bytesWritten, totalBytesExpectedToWrite);\n    }];\n\n```\n\n### Download Progress With Request\n\n```objective-c\n\tSWGETRequest *getR = [[SWGETRequest alloc]init];\n    [getR startDownloadTaskWithURL:@\"http://samples.mplayerhq.hu/A-codecs/ACELP.net/2001-04-11.asf\" parameters:nil parentView:nil cachedData:^(NSCachedURLResponse *response,  NSURL *location) {\n        \n    } success:^(NSURLSessionDownloadTask *uploadTask,  NSURL *location) {\n        NSLog(@\"location %@\", location);\n    } failure:^(NSURLSessionTask *uploadTask, NSError *error) {\n        NSLog(@\"error %@\", error);\n    }];\n    \n    [getR setDownloadProgressBlock:^(long long bytesWritten, long long totalBytesExpectedToWrite) {\n        NSLog(@\"bytesWritten =\u003e %lld and totalBytesExpectedToWrite = %lld\", bytesWritten, totalBytesExpectedToWrite);\n    }];\n```\n\n### Pass object to response block\n\nYou can set custom object to your request object as `userObject` . This will allow any type\n\n```objective-c\nSWGETRequest *getRequest = [[SWGETRequest alloc]init];\ngetRequest.userObject = //any type object.\n\n```\n\n### Identify the Request\nYou can set `tag` for the request\n\n```objective-c\nSWGETRequest *getRequest = [[SWGETRequest alloc]init];\ngetRequest.tag = 12;\n\n```\n\n### Offline request from `SWNetworking`\n\nThis is really simple. First of all you need to send offline request expire time. this is seconds\n\n```objective-c\n    [SWOfflineRequestManger requestExpireTime:1300 ];\n```\n\nYou have methods with parameter passing `sendLaterIfOllfine`. Just pass `YES`. That's it.\n\n```objective-c\n\tSWGETRequest *getR = [[SWGETRequest alloc]init];\n     getR.tag = 400;\n     [getR startDataTaskWithURL:@\"http://www.google.com\" parameters:nil parentView:nil sendLaterIfOffline:YES cachedData:^(NSCachedURLResponse *response, id responseObject) {\n     \n     } success:^(NSURLSessionDataTask *operation, id responseObject) {\n     \n     } failure:^(NSURLSessionTask *operation, NSError *error) {\n\n     }];\n```\nIf you want catch offline request you need to use following methods. Better to add following lines to your `AppDelegate` didFinishLaunchingWithOptions methods.\n\n```objective-c\n\t[[SWOfflineRequestManger sharedInstance] requestSuccessBlock:^(SWRequest *operation, id responseObject) {\n        \n        NSLog(@\"%d\", operation.tag);\n        \n    } requestFailBlock:^(SWRequest *operation, NSError *error) {\n        \n    }];\n```\n\nPlease note you need to set `tag` or `userObject` to identify the request. `userObject` should be `'NSCording' support object \n\n\n### Set Task for UIProgressView\nPlease use following method to set task for UIProgressView\n\n```objective-c\n-(void)setDownloadTask:(NSURLSessionDownloadTask *)downloadTask;\n-(void)setUploadTask:(NSURLSessionUploadTask *)downloadTask;\n```\n# Credits\n\n`SWNetworking` is owned and maintained bye the [SkyWite](http://www.skywite.com)\n`SWNetworking` was originally created by [saman kumara](http://www.isamankumara.com). If you want to contact [me@isamankuamra.com](mailto:me@isamankumara.com)\n\n# Security disclosure\n\nIf you believe you have identified a security vulnerability with `SWNetworking`, you should report it as soon as possible via email to [info@skywite.com](mailto:info@skywite.com). Please do not post it to a public issue tracker.\n\n# License\n\n`SWNetworking` is released under the MIT license. See LICENSE for details.\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskywite%2FSWNetworking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskywite%2FSWNetworking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskywite%2FSWNetworking/lists"}