Permalink
Browse files

Added NSURLConnectionDataDelegate and NSURLConnectionDownloadDelegate…

… to NSURLConnectionDelegate.h
  • Loading branch information...
1 parent 4c88214 commit ebd89fb382fa8d7495423980583a1e2ab23270bc Bleicke Petersen & Onsi Fakhouri committed Jan 6, 2012
@@ -15,7 +15,10 @@
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
- (void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
-// Methods in NSURLConnectionDataDelegate starting in 10.7/iOS5
+@end
+
+@protocol NSURLConnectionDataDelegate <NSURLConnectionDelegate>
+@optional
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response;
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
@@ -31,5 +34,14 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
@end
+@protocol NSURLConnectionDownloadDelegate <NSURLConnectionDelegate>
+@optional
+- (void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long) expectedTotalBytes;
+- (void)connectionDidResumeDownloading:(NSURLConnection *)connection totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long) expectedTotalBytes;
+
+@required
+- (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *) destinationURL;
+@end
+
#endif
#endif
@@ -27,7 +27,7 @@ - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmedia
__block NSURLConnection *connection;
beforeEach(^{
- mockDelegate = [OCMockObject niceMockForProtocol:@protocol(NSURLConnectionDelegate)];
+ mockDelegate = [OCMockObject niceMockForProtocol:@protocol(NSURLConnectionDataDelegate)];
NSURL *url = [NSURL URLWithString:@"http://example.com"];
request = [NSURLRequest requestWithURL:url];
@@ -140,7 +140,7 @@ - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmedia
});
it(@"should not call subsequent delegate methods if cancelled", ^{
- id mockDelegate = [OCMockObject mockForProtocol:@protocol(NSURLConnectionDelegate)];
+ id mockDelegate = [OCMockObject mockForProtocol:@protocol(NSURLConnectionDataDelegate)];
NSURLConnection * myConnection = [(NSURLConnection *)[NSURLConnection alloc] initWithRequest:request delegate:mockDelegate];
@@ -5,13 +5,14 @@
#import "NSURLConnection+Spec.h"
#import "PSHKFakeResponses.h"
#import "PSHKFakeHTTPURLResponse.h"
+#import "NSURLConnectionDelegate.h"
#define HOST "example.com"
#define BASE_PATH "/v1/wibble/"
#define PATH "foo/bar"
@interface TestInterface : PCKHTTPInterface
-- (NSURLConnection *)makeConnectionWithDelegate:(id<NSURLConnectionDelegate>)delegate;
+- (NSURLConnection *)makeConnectionWithDelegate:(id<NSURLConnectionDataDelegate>)delegate;
@end
@implementation TestInterface
@@ -52,7 +53,7 @@ - (NSURLConnection *)makeConnectionWithHeaders:(NSDictionary *)headers andDelega
beforeEach(^{
interface = [[TestInterface alloc] init];
- mockDelegate = [OCMockObject mockForProtocol:@protocol(NSURLConnectionDelegate)];
+ mockDelegate = [OCMockObject mockForProtocol:@protocol(NSURLConnectionDataDelegate)];
});
afterEach(^{
@@ -13,7 +13,7 @@
beforeEach(^{
mockParser = [OCMockObject niceMockForProtocol:@protocol(PCKParser)];
- mockDelegate = [OCMockObject niceMockForProtocol:@protocol(NSURLConnectionDelegate)];
+ mockDelegate = [OCMockObject niceMockForProtocol:@protocol(NSURLConnectionDataDelegate)];
responseParser = [[PCKResponseParser alloc] initWithParser:mockParser andDelegate:mockDelegate];
});

0 comments on commit ebd89fb

Please sign in to comment.