This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended. To summarise this work: - [x] created a new **Xcode** project; - [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project; - [x] created the `Locations` app and also, its `Libraries` package; - [x] created the `Shared` package to share dependencies between the apps; - [x] added a `Makefile` file and implemented some **environment** and **help** commands. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#1
52 lines
1.3 KiB
Objective-C
52 lines
1.3 KiB
Objective-C
#import "ASIHTTPRequestStub.h"
|
|
#import "LSStubResponse.h"
|
|
#import "LSNocilla.h"
|
|
#import "LSASIHTTPRequestAdapter.h"
|
|
#import <objc/runtime.h>
|
|
|
|
@interface ASIHTTPRequestStub ()
|
|
@property (nonatomic, strong) LSStubResponse *stubResponse;
|
|
@end
|
|
|
|
@interface ASIHTTPRequestStub (Private)
|
|
- (void)failWithError:(NSError *)error;
|
|
- (void)requestFinished;
|
|
- (void)markAsFinished;
|
|
@end
|
|
|
|
static void const * ASIHTTPRequestStubResponseKey = &ASIHTTPRequestStubResponseKey;
|
|
|
|
@implementation ASIHTTPRequestStub
|
|
|
|
- (void)setStubResponse:(LSStubResponse *)stubResponse {
|
|
objc_setAssociatedObject(self, ASIHTTPRequestStubResponseKey, stubResponse, OBJC_ASSOCIATION_RETAIN);
|
|
}
|
|
|
|
- (LSStubResponse *)stubResponse {
|
|
return objc_getAssociatedObject(self, ASIHTTPRequestStubResponseKey);
|
|
}
|
|
|
|
- (int)stub_responseStatusCode {
|
|
return (int)self.stubResponse.statusCode;
|
|
}
|
|
|
|
- (NSData *)stub_responseData {
|
|
return self.stubResponse.body;
|
|
}
|
|
|
|
- (NSDictionary *)stub_responseHeaders {
|
|
return self.stubResponse.headers;
|
|
}
|
|
|
|
- (void)stub_startRequest {
|
|
self.stubResponse = [[LSNocilla sharedInstance] responseForRequest:[[LSASIHTTPRequestAdapter alloc] initWithASIHTTPRequest:(id)self]];
|
|
|
|
if (self.stubResponse.shouldFail) {
|
|
[self failWithError:self.stubResponse.error];
|
|
} else {
|
|
[self requestFinished];
|
|
}
|
|
[self markAsFinished];
|
|
}
|
|
|
|
@end |