Latest 1.0.0
Homepage https://github.com/freemiumdev/NSURLSession-SynchronousTask
License MIT
Authors

NSURLSession+SynchronousTask

NSURLSession+SynchronousTask is an NSURLSession category which brings NSURLConnection-like (remember sendSynchronousRequest:returningResponse:error:?) synchronous tasks to NSURLSession.

Internally the category uses GCD to wait for the tasks to finish and NSURLSession‘s shared instance sharedSession to perform the tasks.

Installation

CocoaPods is the recommended method of installing NSURLSession-SynchronousTask. Simply add the following line to your Podfile:

Podfile

pod 'NSURLSession-SynchronousTask'

Usage

NSURLSessionDataTask

NSURL *url = ...
NSError *error = nil;
NSURLResponse *response = nil;
NSData *data = [NSURLSession sendSynchronousDataTaskWithURL:url returningResponse:&response error:&error];
...

NSURLSessionDownloadTask

NSURL *url = ...
NSError *error = nil;
NSURLResponse *response = nil;
NSURL *fileURL = [NSURLSession sendSynchronousDownloadTaskWithURL:url returningResponse:&response error:&error];
...

NSURLSessionUploadTask

NSURLRequest *uploadRequest = ...
NSData *dataToBeUploaded = ...
NSError *error = nil;
NSURLResponse *response = nil;
NSData *data = [NSURLSession sendSynchronousUploadTaskWithRequest:uploadRequest fromData:dataToBeUploaded returningResponse:&response error:&error];
...

Contact

Florian Schliep

License

NSURLSession+SynchronousTask is available under the MIT license. See the LICENSE.txt file for more info.

Latest podspec

{
    "name": "NSURLSession-SynchronousTask",
    "version": "1.0.0",
    "summary": "NSURLSession category which brings NSURLConnection-like synchronous tasks to NSURLSession",
    "description": "                   A longer description of NSURLSession-SynchronousTask in Markdown format.nn                   * Think: Why did you write this? What is the focus? What does it do?n                   * CocoaPods will be using this to generate tags, and improve search results.n                   * Try to keep it short, snappy and to the point.n                   * Finally, don't worry about the indent, CocoaPods strips it!n",
    "homepage": "https://github.com/freemiumdev/NSURLSession-SynchronousTask",
    "license": "MIT",
    "authors": {
        "freemiumdev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/freemiumdev/NSURLSession-SynchronousTask.git",
        "tag": "1.0.0"
    },
    "source_files": "NSURLSession+SynchronousTask"
}

Pin It on Pinterest

Share This