hardcode json
This commit is contained in:
parent
00058468c1
commit
4d86d201df
@ -293,7 +293,7 @@
|
|||||||
- (nullable NSURLSessionTask *)sendRequest:(nonnull MVMCoreRequestParameters *)requestParameters locationForError:(nonnull NSString *)locationForError requestFinished:(nullable void (^)(id _Nullable jsonObject, MVMCoreErrorObject *_Nullable error))requestFinished {
|
- (nullable NSURLSessionTask *)sendRequest:(nonnull MVMCoreRequestParameters *)requestParameters locationForError:(nonnull NSString *)locationForError requestFinished:(nullable void (^)(id _Nullable jsonObject, MVMCoreErrorObject *_Nullable error))requestFinished {
|
||||||
|
|
||||||
#if ENABLE_HARD_CODED_RESPONSE
|
#if ENABLE_HARD_CODED_RESPONSE
|
||||||
NSDictionary *response = [[MFHardCodedServerResponse sharedInstance] getHardCodedResponseForRequest:requestParameters];
|
NSDictionary *response = [[MFHardCodedServerResponse new] getHardCodedResponseForPageType:requestParameters.pageType];
|
||||||
if (response) {
|
if (response) {
|
||||||
if (requestFinished) {
|
if (requestFinished) {
|
||||||
requestFinished(response, nil);
|
requestFinished(response, nil);
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "MVMCoreRequestParameters.h"
|
#import "MVMCoreRequestParameters.h"
|
||||||
|
|
||||||
#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG
|
#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG
|
||||||
|
|
||||||
#if ENABLE_HARD_CODED_RESPONSE
|
#if ENABLE_HARD_CODED_RESPONSE
|
||||||
|
|
||||||
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request;
|
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request;
|
||||||
|
|
||||||
|
- (NSDictionary *) getHardCodedResponseForPageType:(NSString *)pageType;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -56,6 +56,16 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) getHardCodedResponseForPageType:(NSString *)pageType {
|
||||||
|
|
||||||
|
NSError *error;
|
||||||
|
NSString *filePath = [[NSBundle mainBundle] pathForResource:pageType ofType:@"json"];
|
||||||
|
if (filePath) {
|
||||||
|
return [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:filePath] options:NSJSONReadingMutableContainers error:&error];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request {
|
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request {
|
||||||
NSDictionary *cannedResponse = nil;
|
NSDictionary *cannedResponse = nil;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user