diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m index 5bf2864..09617d4 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m @@ -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); diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index a1c3eb9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #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 diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m index 4ed21be..0319f4e 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m @@ -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;