15
15
***************************************************************************/
16
16
17
17
#import < UIKit/UIKit.h>
18
- #import < OptimizelySDKCore/OPTLYLog.h>
19
18
#import < OptimizelySDKCore/OPTLYErrorHandler.h>
19
+ #import < OptimizelySDKCore/OPTLYLog.h>
20
20
#import < OptimizelySDKShared/OPTLYDataStore.h>
21
21
#import < OptimizelySDKShared/OPTLYNetworkService.h>
22
22
#import " OPTLYDatafileManager.h"
@@ -64,21 +64,21 @@ - (void)downloadDatafile:(NSString *)projectId completionHandler:(OPTLYHTTPReque
64
64
OPTLYLogInfo (@" Downloading datafile: %@ " , projectId);
65
65
[self .networkService downloadProjectConfig: self .projectId
66
66
completionHandler: ^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
67
- if (error != nil ) {
68
- [self .errorHandler handleError: error];
69
- }
70
- else if ([(NSHTTPURLResponse *)response statusCode ] == 200 ) { // got datafile OK
71
- [self saveDatafile: data];
72
- OPTLYLogInfo (@" Datafile for project ID %@ downloaded. Saving datafile." );
73
- }
74
- else {
75
- // TODO: Josh W. handle bad response
76
- }
77
- // call the completion handler
78
- if (completion != nil ) {
79
- completion (data, response, error);
80
- }
81
- }];
67
+ if (error != nil ) {
68
+ [self .errorHandler handleError: error];
69
+ }
70
+ else if ([(NSHTTPURLResponse *)response statusCode ] == 200 ) { // got datafile OK
71
+ [self saveDatafile: data];
72
+ OPTLYLogInfo (@" Datafile for project ID %@ downloaded. Saving datafile." );
73
+ }
74
+ else {
75
+ // TODO: Josh W. handle bad response
76
+ }
77
+ // call the completion handler
78
+ if (completion != nil ) {
79
+ completion (data, response, error);
80
+ }
81
+ }];
82
82
}
83
83
84
84
- (void )downloadDatafile {
@@ -94,6 +94,11 @@ - (void)saveDatafile:(NSData *)datafile {
94
94
95
95
}
96
96
97
+ - (BOOL )isDatafileCached {
98
+ BOOL isCached = [self .dataStore fileExists: self .projectId type: OPTLYDataStoreDataTypeDatafile];
99
+ return isCached;
100
+ }
101
+
97
102
#pragma mark - Application Lifecycle Handlers
98
103
- (void )setupApplicationNotificationHandlers {
99
104
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter ];
0 commit comments