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 {
|
||||
|
||||
#if ENABLE_HARD_CODED_RESPONSE
|
||||
NSDictionary *response = [[MFHardCodedServerResponse sharedInstance] getHardCodedResponseForRequest:requestParameters];
|
||||
NSDictionary *response = [[MFHardCodedServerResponse new] getHardCodedResponseForPageType:requestParameters.pageType];
|
||||
if (response) {
|
||||
if (requestFinished) {
|
||||
requestFinished(response, nil);
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MVMCoreRequestParameters.h"
|
||||
|
||||
#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG
|
||||
#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG
|
||||
|
||||
#if ENABLE_HARD_CODED_RESPONSE
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
|
||||
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request;
|
||||
|
||||
- (NSDictionary *) getHardCodedResponseForPageType:(NSString *)pageType;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@ -56,6 +56,16 @@
|
||||
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 *cannedResponse = nil;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user