Latest 0.0.2
Homepage https://github.com/PearTreeLabs/PTLURLProtocol
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit
Authors

Description

A helpful wrapper for testing network requests using NSURLProtocol.

PTLURLProtocol is designed to be very basic, just a wrapper around boilerplate logic when subclassing NSURLProtocol. If you want something more advanced you should take a look at OHHTTPStubs.

Usage

  • Subclass PTLURLProtocol
@interface MyCustomURLProtocol : PTLURLProtocol
@end
  • Override 3 methods
@implementation MyCustomURLProtocol
+ (BOOL)canInitWithRequest:(NSURLRequest *)request {...}
+ (NSURLResponse *)responseForRequest:(NSURLRequest *)request {...}
+ (NSData *)dataForRequest:(NSURLRequest *)request {...}
@end
  • Register your custom protocol
[MyCustomURLProtocol registerProtocol];
  • Profit

License

MIT

Thanks

@mattt for introducing the idea on NSHipster.

Contact

Brian Partridge – @brianpartridge on Twitter and App.Net

Latest podspec

{
    "name": "PTLURLProtocol",
    "version": "0.0.2",
    "summary": "A helpful wrapper for testing network requests using NSURLProtocol",
    "homepage": "https://github.com/PearTreeLabs/PTLURLProtocol",
    "license": {
        "type": "MIT",
        "file": "LICENSE.txt"
    },
    "authors": {
        "Brian Partridge": "[email protected]"
    },
    "source": {
        "git": "https://github.com/PearTreeLabs/PTLURLProtocol.git",
        "tag": "0.0.2"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "PTLURLProtocol/*.{h,m}",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This