PTLURLProtocol 0.0.2

PTLURLProtocol 0.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.



  • By
  • Brian Partridge

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