From 20313b99082d6198f23b21a13ae3a487349dd4d0 Mon Sep 17 00:00:00 2001 From: Pascal Pfiffner Date: Thu, 14 May 2015 14:57:31 -0400 Subject: [PATCH] Convert APCDataSubstrate to protocol See #43 --- .../APCAppCore.xcodeproj/project.pbxproj | 40 +++--- APCAppCore/APCAppCore/APCAppCore.h | 4 +- .../APCAppCore/DataMonitor/APCDataMonitor.h | 10 +- .../APCAppCore/DataMonitor/APCDataMonitor.m | 2 +- ...it.h => APCAppDataSubstrate+ResearchKit.h} | 6 +- ...it.m => APCAppDataSubstrate+ResearchKit.m} | 6 +- .../DataSubstrate/APCAppDataSubstrate.h | 94 ++++++++++++++ ...CDataSubstrate.m => APCAppDataSubstrate.m} | 8 +- .../DataSubstrate/APCCoreDataSubstrate.h | 61 +++++++++ .../DataSubstrate/APCDataSubstrate.h | 117 ++++++------------ .../DataSubstrate/Model/APCSchedule+Bridge.m | 4 +- .../DataSubstrate/Model/APCTask+Bridge.m | 4 +- .../APCAppCore/DataSubstrate/Model/APCUser.m | 4 +- .../Library/Scheduler/APCScheduler.h | 14 +-- .../Library/Scheduler/APCScheduler.m | 12 +- .../APCAppCore/Startup/APCAppDelegate.h | 6 +- .../APCAppCore/Startup/APCAppDelegate.m | 2 +- .../APCTasksAndSchedulesMigrationUtility.h | 9 +- .../TasksAndSteps/APCBaseTaskViewController.m | 3 +- 19 files changed, 269 insertions(+), 137 deletions(-) rename APCAppCore/APCAppCore/DataSubstrate/{APCDataSubstrate+ResearchKit.h => APCAppDataSubstrate+ResearchKit.h} (94%) rename APCAppCore/APCAppCore/DataSubstrate/{APCDataSubstrate+ResearchKit.m => APCAppDataSubstrate+ResearchKit.m} (96%) create mode 100644 APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.h rename APCAppCore/APCAppCore/DataSubstrate/{APCDataSubstrate.m => APCAppDataSubstrate.m} (99%) create mode 100644 APCAppCore/APCAppCore/DataSubstrate/APCCoreDataSubstrate.h diff --git a/APCAppCore/APCAppCore.xcodeproj/project.pbxproj b/APCAppCore/APCAppCore.xcodeproj/project.pbxproj index 9a1f241b..8993aef0 100644 --- a/APCAppCore/APCAppCore.xcodeproj/project.pbxproj +++ b/APCAppCore/APCAppCore.xcodeproj/project.pbxproj @@ -326,6 +326,8 @@ EE028FE41AF94B36001C8251 /* APCKeychainStore+Passcode.m in Sources */ = {isa = PBXBuildFile; fileRef = EE028FE21AF94B36001C8251 /* APCKeychainStore+Passcode.m */; }; EE4B95251AF82BA6000097C7 /* NSError+Bridge.h in Headers */ = {isa = PBXBuildFile; fileRef = EE4B95231AF82BA6000097C7 /* NSError+Bridge.h */; }; EE4B95261AF82BA6000097C7 /* NSError+Bridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EE4B95241AF82BA6000097C7 /* NSError+Bridge.m */; }; + EEF68D031B051FD6004A8AA0 /* APCCoreDataSubstrate.h in Headers */ = {isa = PBXBuildFile; fileRef = EEF68D021B051FD6004A8AA0 /* APCCoreDataSubstrate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + EEF68D051B05200F004A8AA0 /* APCDataSubstrate.h in Headers */ = {isa = PBXBuildFile; fileRef = EEF68D041B05200F004A8AA0 /* APCDataSubstrate.h */; settings = {ATTRIBUTES = (Public, ); }; }; F50738C01A682E12004CF100 /* APCDateRange.h in Headers */ = {isa = PBXBuildFile; fileRef = F50738BE1A682E12004CF100 /* APCDateRange.h */; settings = {ATTRIBUTES = (Public, ); }; }; F50738C11A682E12004CF100 /* APCDateRange.m in Sources */ = {isa = PBXBuildFile; fileRef = F50738BF1A682E12004CF100 /* APCDateRange.m */; }; F5306CCD1A8BE7F600732E60 /* ORKQuestionResult+APCHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = F5306CCB1A8BE7F600732E60 /* ORKQuestionResult+APCHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -495,10 +497,10 @@ F5F129E31A2F78490015982C /* APCDataMonitor+Bridge.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F128861A2F78490015982C /* APCDataMonitor+Bridge.m */; }; F5F129E41A2F78490015982C /* APCDataMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F128871A2F78490015982C /* APCDataMonitor.h */; settings = {ATTRIBUTES = (Public, ); }; }; F5F129E51A2F78490015982C /* APCDataMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F128881A2F78490015982C /* APCDataMonitor.m */; }; - F5F129EA1A2F78490015982C /* APCDataSubstrate+ResearchKit.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F1288E1A2F78490015982C /* APCDataSubstrate+ResearchKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - F5F129EB1A2F78490015982C /* APCDataSubstrate+ResearchKit.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F1288F1A2F78490015982C /* APCDataSubstrate+ResearchKit.m */; }; - F5F129EC1A2F78490015982C /* APCDataSubstrate.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F128901A2F78490015982C /* APCDataSubstrate.h */; settings = {ATTRIBUTES = (Public, ); }; }; - F5F129ED1A2F78490015982C /* APCDataSubstrate.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F128911A2F78490015982C /* APCDataSubstrate.m */; }; + F5F129EA1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F1288E1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F5F129EB1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F1288F1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.m */; }; + F5F129EC1A2F78490015982C /* APCAppDataSubstrate.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F128901A2F78490015982C /* APCAppDataSubstrate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F5F129ED1A2F78490015982C /* APCAppDataSubstrate.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F128911A2F78490015982C /* APCAppDataSubstrate.m */; }; F5F129EE1A2F78490015982C /* APCDBStatus+AddOn.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F128931A2F78490015982C /* APCDBStatus+AddOn.h */; settings = {ATTRIBUTES = (Public, ); }; }; F5F129EF1A2F78490015982C /* APCDBStatus+AddOn.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F128941A2F78490015982C /* APCDBStatus+AddOn.m */; }; F5F129F01A2F78490015982C /* APCDBStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = F5F128951A2F78490015982C /* APCDBStatus.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1009,6 +1011,8 @@ EE028FE21AF94B36001C8251 /* APCKeychainStore+Passcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "APCKeychainStore+Passcode.m"; sourceTree = ""; }; EE4B95231AF82BA6000097C7 /* NSError+Bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+Bridge.h"; sourceTree = ""; }; EE4B95241AF82BA6000097C7 /* NSError+Bridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+Bridge.m"; sourceTree = ""; }; + EEF68D021B051FD6004A8AA0 /* APCCoreDataSubstrate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCCoreDataSubstrate.h; sourceTree = ""; }; + EEF68D041B05200F004A8AA0 /* APCDataSubstrate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCDataSubstrate.h; sourceTree = ""; }; F50738BE1A682E12004CF100 /* APCDateRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCDateRange.h; sourceTree = ""; }; F50738BF1A682E12004CF100 /* APCDateRange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APCDateRange.m; sourceTree = ""; }; F5179B2919D09128001DCCB7 /* APCAppCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = APCAppCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1179,10 +1183,10 @@ F5F128861A2F78490015982C /* APCDataMonitor+Bridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "APCDataMonitor+Bridge.m"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; F5F128871A2F78490015982C /* APCDataMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCDataMonitor.h; sourceTree = ""; }; F5F128881A2F78490015982C /* APCDataMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = APCDataMonitor.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - F5F1288E1A2F78490015982C /* APCDataSubstrate+ResearchKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "APCDataSubstrate+ResearchKit.h"; sourceTree = ""; }; - F5F1288F1A2F78490015982C /* APCDataSubstrate+ResearchKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "APCDataSubstrate+ResearchKit.m"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - F5F128901A2F78490015982C /* APCDataSubstrate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCDataSubstrate.h; sourceTree = ""; }; - F5F128911A2F78490015982C /* APCDataSubstrate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APCDataSubstrate.m; sourceTree = ""; }; + F5F1288E1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "APCAppDataSubstrate+ResearchKit.h"; sourceTree = ""; }; + F5F1288F1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "APCAppDataSubstrate+ResearchKit.m"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + F5F128901A2F78490015982C /* APCAppDataSubstrate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCAppDataSubstrate.h; sourceTree = ""; }; + F5F128911A2F78490015982C /* APCAppDataSubstrate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APCAppDataSubstrate.m; sourceTree = ""; }; F5F128931A2F78490015982C /* APCDBStatus+AddOn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "APCDBStatus+AddOn.h"; sourceTree = ""; }; F5F128941A2F78490015982C /* APCDBStatus+AddOn.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "APCDBStatus+AddOn.m"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; F5F128951A2F78490015982C /* APCDBStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCDBStatus.h; sourceTree = ""; }; @@ -2380,10 +2384,12 @@ F5F128891A2F78490015982C /* DataSubstrate */ = { isa = PBXGroup; children = ( - F5F128901A2F78490015982C /* APCDataSubstrate.h */, - F5F128911A2F78490015982C /* APCDataSubstrate.m */, - F5F1288E1A2F78490015982C /* APCDataSubstrate+ResearchKit.h */, - F5F1288F1A2F78490015982C /* APCDataSubstrate+ResearchKit.m */, + EEF68D041B05200F004A8AA0 /* APCDataSubstrate.h */, + EEF68D021B051FD6004A8AA0 /* APCCoreDataSubstrate.h */, + F5F128901A2F78490015982C /* APCAppDataSubstrate.h */, + F5F128911A2F78490015982C /* APCAppDataSubstrate.m */, + F5F1288E1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.h */, + F5F1288F1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.m */, F5F128921A2F78490015982C /* Model */, ); path = DataSubstrate; @@ -2867,6 +2873,7 @@ CFFDED731A95731F00B25581 /* APCMedicationTrackerCalendarWeeklyView.h in Headers */, F5F12AF01A2F78490015982C /* APCDashboardProgressTableViewCell.h in Headers */, 08EA2AB31A7AD564007549C0 /* UIImage+ImageEffects.h in Headers */, + EEF68D051B05200F004A8AA0 /* APCDataSubstrate.h in Headers */, 5BB10C0A1A91D540002D2DD2 /* APCStudyVideoCollectionViewCell.h in Headers */, 5BD6EBC41A9D905100C3BFB0 /* APCPermissionPrimingViewController.h in Headers */, 3654318D1A9A7BC200D66D97 /* APCMedTrackerInflatableItem.h in Headers */, @@ -2932,6 +2939,7 @@ CFEF5CAD1A807DE4009A8634 /* APCCustomBackButton.h in Headers */, F5B946411A7309A20034C522 /* ZZOldArchiveEntry.h in Headers */, CFFDEDEF1A95734000B25581 /* APCMedicationNameViewController.h in Headers */, + EEF68D031B051FD6004A8AA0 /* APCCoreDataSubstrate.h in Headers */, CFFDEDE31A95734000B25581 /* APCColorSwatchTableViewCell.h in Headers */, F5F12ADE1A2F78490015982C /* APCShareTableViewCell.h in Headers */, F5F12AE41A2F78490015982C /* APCTintedTableViewCell.h in Headers */, @@ -2950,7 +2958,7 @@ 7B6C8CBF1AA26ECE0007B560 /* APCConsentTextChoiceQuestion.h in Headers */, 7B0DC4141A5EFDDA0072EE80 /* APCActivitiesViewWithNoTask.h in Headers */, 36AAB3541A9A760D00FAC255 /* APCMedTrackerPrescriptionColor.h in Headers */, - F5F129EA1A2F78490015982C /* APCDataSubstrate+ResearchKit.h in Headers */, + F5F129EA1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.h in Headers */, F5306CCD1A8BE7F600732E60 /* ORKQuestionResult+APCHelper.h in Headers */, F5B947E11A73272C0034C522 /* APCDeviceHardware.h in Headers */, F5B946361A7309A20034C522 /* ZZFileChannel.h in Headers */, @@ -3086,7 +3094,7 @@ 3627D34C1A9A7517006B02E8 /* APCMedTrackerPossibleDosage.h in Headers */, 369E27FC1A96B7A200D35DFA /* APCMedicationWeeklySchedule.h in Headers */, F5F129F81A2F78490015982C /* APCResult.h in Headers */, - F5F129EC1A2F78490015982C /* APCDataSubstrate.h in Headers */, + F5F129EC1A2F78490015982C /* APCAppDataSubstrate.h in Headers */, 5B827B551A80CB0400C685A3 /* APCFadeAnimator.h in Headers */, F5B946341A7309A20034C522 /* ZZError.h in Headers */, 369E27FE1A96B7A200D35DFA /* APCMedTrackerDailyDosageRecord+Helper.h in Headers */, @@ -3456,12 +3464,12 @@ CFFDED7F1A95731F00B25581 /* NSDictionary+MedicationTracker.m in Sources */, F5F12A721A2F78490015982C /* APCConcentricProgressView.m in Sources */, 7BA5D99F1AA43F50006F505F /* APCStoredUserData.m in Sources */, - F5F129ED1A2F78490015982C /* APCDataSubstrate.m in Sources */, + F5F129ED1A2F78490015982C /* APCAppDataSubstrate.m in Sources */, F5B947FF1A73272C0034C522 /* APCScheduleExpression.m in Sources */, F5306CCE1A8BE7F600732E60 /* ORKQuestionResult+APCHelper.m in Sources */, CFFDEDF01A95734000B25581 /* APCMedicationNameViewController.m in Sources */, F54DDD261A8026010073E4B4 /* APCCoreMotionTracker.m in Sources */, - F5F129EB1A2F78490015982C /* APCDataSubstrate+ResearchKit.m in Sources */, + F5F129EB1A2F78490015982C /* APCAppDataSubstrate+ResearchKit.m in Sources */, 3627D34D1A9A7517006B02E8 /* APCMedTrackerPossibleDosage.m in Sources */, 5B9B36A41A95D9B500389F42 /* APCActivitiesTintedTableViewCell.m in Sources */, F5F12AC61A2F78490015982C /* APCLearnStudyDetailsViewController.m in Sources */, diff --git a/APCAppCore/APCAppCore/APCAppCore.h b/APCAppCore/APCAppCore/APCAppCore.h index 9822f392..61305745 100644 --- a/APCAppCore/APCAppCore/APCAppCore.h +++ b/APCAppCore/APCAppCore/APCAppCore.h @@ -46,8 +46,8 @@ FOUNDATION_EXPORT const unsigned char APCAppCoreVersionString[]; #import #import #import -#import -#import +#import +#import #import #import #import diff --git a/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.h b/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.h index 394ed36b..863a0697 100644 --- a/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.h +++ b/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.h @@ -31,15 +31,15 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#import #import +#import "APCCoreDataSubstrate.h" -@class APCDataSubstrate, APCScheduler; +@class APCScheduler; @interface APCDataMonitor : NSObject -- (instancetype)initWithDataSubstrate: (APCDataSubstrate*) dataSubstrate scheduler: (APCScheduler*) scheduler; +- (instancetype)initWithDataSubstrate:(id)dataSubstrate scheduler:(APCScheduler *)scheduler; - (void) appFinishedLaunching; - (void) appBecameActive; @@ -53,8 +53,8 @@ /*********************************************************************************/ //Declaring as weak so as not to hold on to below objects -@property (weak, nonatomic) APCDataSubstrate * dataSubstrate; -@property (weak, nonatomic) APCScheduler * scheduler; +@property (weak, nonatomic) id dataSubstrate; +@property (weak, nonatomic) APCScheduler *scheduler; @property (nonatomic) BOOL batchUploadingInProgress; @end diff --git a/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.m b/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.m index 9fac5be8..a197a5c8 100644 --- a/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.m +++ b/APCAppCore/APCAppCore/DataMonitor/APCDataMonitor.m @@ -41,7 +41,7 @@ @interface APCDataMonitor () @implementation APCDataMonitor -- (instancetype)initWithDataSubstrate:(APCDataSubstrate *)dataSubstrate scheduler:(APCScheduler *)scheduler +- (instancetype)initWithDataSubstrate:(id)dataSubstrate scheduler:(APCScheduler *)scheduler { self = [super init]; if (self) { diff --git a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate+ResearchKit.h b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate+ResearchKit.h similarity index 94% rename from APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate+ResearchKit.h rename to APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate+ResearchKit.h index 35e9e33f..bbb46a63 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate+ResearchKit.h +++ b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate+ResearchKit.h @@ -1,5 +1,5 @@ // -// APCDataSubstrate+ResearchKit.h +// APCAppDataSubstrate+ResearchKit.h // APCAppCore // // Copyright (c) 2015, Apple Inc. All rights reserved. @@ -31,9 +31,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#import "APCDataSubstrate.h" +#import "APCAppDataSubstrate.h" -@interface APCDataSubstrate (ResearchKit) +@interface APCAppDataSubstrate (ResearchKit) /*********************************************************************************/ #pragma mark - Methods meant only for Categories diff --git a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate+ResearchKit.m b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate+ResearchKit.m similarity index 96% rename from APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate+ResearchKit.m rename to APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate+ResearchKit.m index 5d7a5205..48d9ff84 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate+ResearchKit.m +++ b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate+ResearchKit.m @@ -1,5 +1,5 @@ // -// APCDataSubstrate+ResearchKit.m +// APCAppDataSubstrate+ResearchKit.m // APCAppCore // // Copyright (c) 2015, Apple Inc. All rights reserved. @@ -31,7 +31,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#import "APCDataSubstrate+ResearchKit.h" +#import "APCAppDataSubstrate+ResearchKit.h" #import "APCAppCore.h" #import @@ -48,7 +48,7 @@ //static NSInteger const APCDataLoggerManagerMaximumInputBytes = 10; //static NSInteger const APCDataLoggerManagerMaximumFiles = 0; -@implementation APCDataSubstrate (ResearchKit) +@implementation APCAppDataSubstrate (ResearchKit) /*********************************************************************************/ #pragma mark - ResearchKit Subsystem diff --git a/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.h b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.h new file mode 100644 index 00000000..29456d74 --- /dev/null +++ b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.h @@ -0,0 +1,94 @@ +// +// APCAppDataSubstrate.h +// APCAppCore +// +// Copyright (c) 2015, Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder(s) nor the names of any contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. No license is granted to the trademarks of +// the copyright holders even if such marks are included in this software. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#import +#import +#import +#import "APCCoreDataSubstrate.h" + +@class APCUser; + +@interface APCAppDataSubstrate : NSObject + + +#pragma mark - Initializer + +- (instancetype)initWithPersistentStorePath:(NSString *)storePath additionalModels:(NSManagedObjectModel *)mergedModels studyIdentifier:(NSString *)studyIdentifier; + + +#pragma mark - ResearchKit Subsystem Public Properties & Passive Location Tracking + +@property (assign) BOOL justJoined; +@property (strong, nonatomic) NSString *logDirectory; +@property (nonatomic, strong) APCUser *currentUser; + + +#pragma mark - CoreData + +@property (nonatomic, strong) NSString *storePath; +@property (nonatomic, strong) NSPersistentStoreCoordinator *persistentStoreCoordinator; +@property (nonatomic, strong) NSManagedObjectModel *managedObjectModel; + +/** Main context for use in View Controllers, Fetch Results Controllers etc. */ +@property (nonatomic, strong) NSManagedObjectContext * mainContext; + +/** Persistent context: Parent of main context. + * Please create a child context of persistentContext for any background processing tasks. + */ +@property (nonatomic, strong) NSManagedObjectContext * persistentContext; + + +#pragma mark - Core Data Public Methods + +- (void)loadStaticTasksAndSchedules:(NSDictionary *)jsonDictionary; + +/** EXERCISE CAUTION IN CALLING THIS METHOD. */ +- (void)resetCoreData; + + +#pragma mark - Core Data Helpers - ONLY RETURNS in NSManagedObjects in mainContext + +- (NSUInteger)countOfAllScheduledTasksForToday; +- (NSUInteger)countOfCompletedScheduledTasksForToday; + + +#pragma mark - HealthKit + +@property (nonatomic, strong) HKHealthStore *healthStore; + + +#pragma mark - Parameters + +@property (strong, nonatomic) APCParameters *parameters; + +@end diff --git a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.m b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.m similarity index 99% rename from APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.m rename to APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.m index 640e06e4..d969fa2b 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.m +++ b/APCAppCore/APCAppCore/DataSubstrate/APCAppDataSubstrate.m @@ -1,5 +1,5 @@ // -// APCDataSubstrate.m +// APCAppDataSubstrate.m // APCAppCore // // Copyright (c) 2015, Apple Inc. All rights reserved. @@ -31,7 +31,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#import "APCDataSubstrate.h" +#import "APCAppDataSubstrate.h" #import "APCConstants.h" #import "APCUser.h" #import "APCAppDelegate.h" // should be replaced @@ -63,14 +63,14 @@ -@interface APCDataSubstrate () +@interface APCAppDataSubstrate () @property (strong, nonatomic) NSTimer *dateChangeTestTimer;//refreshes Activities if the date crosses midnight. @property (strong, nonatomic) NSDate *tomorrowAtMidnight; @end -@implementation APCDataSubstrate +@implementation APCAppDataSubstrate - (void)dealloc { diff --git a/APCAppCore/APCAppCore/DataSubstrate/APCCoreDataSubstrate.h b/APCAppCore/APCAppCore/DataSubstrate/APCCoreDataSubstrate.h new file mode 100644 index 00000000..5b217f4a --- /dev/null +++ b/APCAppCore/APCAppCore/DataSubstrate/APCCoreDataSubstrate.h @@ -0,0 +1,61 @@ +// +// APCCoreDataSubstrate.h +// APCAppCore +// +// Copyright (c) 2015, Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder(s) nor the names of any contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. No license is granted to the trademarks of +// the copyright holders even if such marks are included in this software. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#import "APCDataSubstrate.h" +#import + + +/** + * Extended APCDataSubstrate for data substrates that use CoreData. + */ +@protocol APCCoreDataSubstrate + +@property (nonatomic, strong) NSPersistentStoreCoordinator *persistentStoreCoordinator; + +/** Main context for use in View Controllers, Fetch Results Controllers etc. */ +@property (nonatomic, strong) NSManagedObjectContext *mainContext; + +/** Persistent context: Parent of main context. + * Please create a child context of persistentContext for any background processing tasks. + */ +@property (nonatomic, strong) NSManagedObjectContext *persistentContext; + +- (void)loadStaticTasksAndSchedules:(NSDictionary *)jsonDictionary; + +- (NSUInteger)countOfAllScheduledTasksForToday; + +- (NSUInteger)countOfCompletedScheduledTasksForToday; + +- (void)resetCoreData; + +@end diff --git a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.h b/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.h index dcd242fb..070d4e24 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.h +++ b/APCAppCore/APCAppCore/DataSubstrate/APCDataSubstrate.h @@ -1,94 +1,55 @@ -// -// APCDataSubstrate.h -// APCAppCore -// -// Copyright (c) 2015, Apple Inc. All rights reserved. -// +// +// APCDataSubstrate.h +// APCAppCore +// +// Copyright (c) 2015, Apple Inc. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation and/or -// other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder(s) nor the names of any contributors -// may be used to endorse or promote products derived from this software without -// specific prior written permission. No license is granted to the trademarks of -// the copyright holders even if such marks are included in this software. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#import -#import -#import +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder(s) nor the names of any contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. No license is granted to the trademarks of +// the copyright holders even if such marks are included in this software. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + #import "APCParameters.h" +#import @class APCUser; -@interface APCDataSubstrate : NSObject - - -#pragma mark - Initializer - -- (instancetype)initWithPersistentStorePath:(NSString *)storePath additionalModels:(NSManagedObjectModel *)mergedModels studyIdentifier:(NSString *)studyIdentifier; - - -#pragma mark - ResearchKit Subsystem Public Properties & Passive Location Tracking - -@property (assign) BOOL justJoined; -@property (strong, nonatomic) NSString *logDirectory; -@property (nonatomic, strong) APCUser *currentUser; - - -#pragma mark - CoreData - -@property (nonatomic, strong) NSString *storePath; -@property (nonatomic, strong) NSPersistentStoreCoordinator *persistentStoreCoordinator; -@property (nonatomic, strong) NSManagedObjectModel *managedObjectModel; +NS_ASSUME_NONNULL_BEGIN -/** Main context for use in View Controllers, Fetch Results Controllers etc. */ -@property (nonatomic, strong) NSManagedObjectContext * mainContext; -/** Persistent context: Parent of main context. - * Please create a child context of persistentContext for any background processing tasks. +/** + * Base data substrate protocol. */ -@property (nonatomic, strong) NSManagedObjectContext * persistentContext; +@protocol APCDataSubstrate +@property (strong, nonatomic, readonly, nullable) APCUser *currentUser; -#pragma mark - Core Data Public Methods +@property (strong, nonatomic, readonly, nullable) APCParameters *parameters; -- (void)loadStaticTasksAndSchedules:(NSDictionary *)jsonDictionary; - -/** EXERCISE CAUTION IN CALLING THIS METHOD. */ -- (void)resetCoreData; - - -#pragma mark - Core Data Helpers - ONLY RETURNS in NSManagedObjects in mainContext - -- (NSUInteger)countOfAllScheduledTasksForToday; -- (NSUInteger)countOfCompletedScheduledTasksForToday; - - -#pragma mark - HealthKit - -@property (nonatomic, strong) HKHealthStore *healthStore; - - -#pragma mark - Parameters - -@property (strong, nonatomic) APCParameters *parameters; +@property (strong, nonatomic, readonly, nullable) HKHealthStore *healthStore; @end + +NS_ASSUME_NONNULL_END diff --git a/APCAppCore/APCAppCore/DataSubstrate/Model/APCSchedule+Bridge.m b/APCAppCore/APCAppCore/DataSubstrate/Model/APCSchedule+Bridge.m index ae943fbb..68fc8813 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/Model/APCSchedule+Bridge.m +++ b/APCAppCore/APCAppCore/DataSubstrate/Model/APCSchedule+Bridge.m @@ -32,6 +32,7 @@ // #import "APCSchedule+Bridge.h" +#import "APCCoreDataSubstrate.h" #import "APCAppDelegate.h" #import "APCTask.h" #import "APCLog.h" @@ -62,7 +63,8 @@ + (void) updateSchedulesOnCompletion: (void (^)(NSError * error)) completionBloc SBBResourceList *list = (SBBResourceList *)schedulesList; NSArray * schedules = list.items; NSManagedObjectContext * context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; - context.parentContext = ((APCAppDelegate*)[UIApplication sharedApplication].delegate).dataSubstrate.persistentContext; + id dataSubstrate = ((APCAppDelegate*)[UIApplication sharedApplication].delegate).dataSubstrate; + context.parentContext = dataSubstrate.persistentContext; [self clearAllRemoteUpdatableSchedules:context]; [context performBlockAndWait:^{ [schedules enumerateObjectsUsingBlock:^(SBBSchedule* schedule, NSUInteger __unused idx, BOOL * __unused stop) { diff --git a/APCAppCore/APCAppCore/DataSubstrate/Model/APCTask+Bridge.m b/APCAppCore/APCAppCore/DataSubstrate/Model/APCTask+Bridge.m index 795ab7a2..0d19cc9c 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/Model/APCTask+Bridge.m +++ b/APCAppCore/APCAppCore/DataSubstrate/Model/APCTask+Bridge.m @@ -32,6 +32,7 @@ // #import "APCTask+Bridge.h" +#import "APCCoreDataSubstrate.h" #import "APCSmartSurveyTask.h" #import "APCAppDelegate.h" #import "APCLog.h" @@ -59,7 +60,8 @@ + (BOOL) serverDisabled + (void)refreshSurveysOnCompletion: (void (^)(NSError * error)) completionBlock { - NSManagedObjectContext * context = ((APCAppDelegate*)[UIApplication sharedApplication].delegate).dataSubstrate.persistentContext; + id dataSubstrate = ((APCAppDelegate*)[UIApplication sharedApplication].delegate).dataSubstrate; + NSManagedObjectContext *context = dataSubstrate.persistentContext; NSFetchRequest * request = [APCTask request]; request.predicate = [NSPredicate predicateWithFormat:@"taskDescription == nil && taskHRef != nil"]; [context performBlockAndWait:^{ diff --git a/APCAppCore/APCAppCore/DataSubstrate/Model/APCUser.m b/APCAppCore/APCAppCore/DataSubstrate/Model/APCUser.m index 7f046b44..98994460 100644 --- a/APCAppCore/APCAppCore/DataSubstrate/Model/APCUser.m +++ b/APCAppCore/APCAppCore/DataSubstrate/Model/APCUser.m @@ -32,6 +32,7 @@ // #import "APCUser.h" +#import "APCCoreDataSubstrate.h" #import "APCStoredUserData.h" #import "APCAppDelegate.h" #import "APCDataSubstrate.h" @@ -186,7 +187,8 @@ - (void)copyPropertiesFromStoredUserData:(APCStoredUserData*)storedUserData - (void)updateStoredProperty:(NSString *)propertyName withValue:(id)value { - NSManagedObjectContext * context = [(APCAppDelegate*) [UIApplication sharedApplication].delegate dataSubstrate].persistentContext; + id dataSubstrate = ((APCAppDelegate*)[UIApplication sharedApplication].delegate).dataSubstrate; + NSManagedObjectContext *context = dataSubstrate.persistentContext; [context performBlockAndWait:^{ APCStoredUserData *storedUserData = [self loadStoredUserDataInContext:context]; [storedUserData setValue:value forKey:propertyName]; diff --git a/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.h b/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.h index 02552229..18c68663 100644 --- a/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.h +++ b/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.h @@ -31,8 +31,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#import #import +#import "APCCoreDataSubstrate.h" @class APCDataSubstrate; @class APCSchedule; @@ -47,15 +47,15 @@ typedef NS_ENUM(NSUInteger, APCSchedulerDateRange) { @interface APCScheduler : NSObject -- (instancetype) initWithDataSubstrate: (APCDataSubstrate*) dataSubstrate; +- (instancetype)initWithDataSubstrate:(id)dataSubstrate; -- (void)updateScheduledTasksIfNotUpdating: (BOOL) today; -- (void)updateScheduledTasksIfNotUpdatingWithRange: (APCSchedulerDateRange) range; -- (void) updateScheduledTasksForSchedule: (APCSchedule*) schedule; +- (void)updateScheduledTasksIfNotUpdating:(BOOL)today; +- (void)updateScheduledTasksIfNotUpdatingWithRange:(APCSchedulerDateRange)range; +- (void) updateScheduledTasksForSchedule:(APCSchedule *)schedule; -@property (nonatomic, strong) APCDateRange * referenceRange; +@property (nonatomic, strong) APCDateRange *referenceRange; -- (void) findOrCreateOneTimeScheduledTask:(APCSchedule *) schedule task: (APCTask*) task andStartDateReference: (NSDate *)startOn; +- (void) findOrCreateOneTimeScheduledTask:(APCSchedule *)schedule task:(APCTask *)task andStartDateReference:(NSDate *)startOn; @end diff --git a/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.m b/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.m index 2b20152c..a3a5105a 100644 --- a/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.m +++ b/APCAppCore/APCAppCore/Library/Scheduler/APCScheduler.m @@ -39,16 +39,16 @@ static NSString * const kOneTimeSchedule = @"once"; @interface APCScheduler() -@property (weak, nonatomic) APCDataSubstrate *dataSubstrate; -@property (strong, nonatomic) NSManagedObjectContext *scheduleMOC; -@property (nonatomic) BOOL isUpdating; +@property (weak, nonatomic) id dataSubstrate; +@property (strong, nonatomic) NSManagedObjectContext *scheduleMOC; +@property (nonatomic) BOOL isUpdating; @property (nonatomic, strong) NSDateFormatter * dateFormatter; //Properties that need to be cleaned after every upate -@property (nonatomic, strong) NSMutableArray * allScheduledTasksForReferenceDate; -@property (nonatomic, strong) NSMutableArray * validatedScheduledTasksForReferenceDate; +@property (nonatomic, strong) NSMutableArray *allScheduledTasksForReferenceDate; +@property (nonatomic, strong) NSMutableArray *validatedScheduledTasksForReferenceDate; @end @@ -63,7 +63,7 @@ - (NSDateFormatter *)dateFormatter { return _dateFormatter; } -- (instancetype)initWithDataSubstrate: (APCDataSubstrate*) dataSubstrate +- (instancetype)initWithDataSubstrate:(id)dataSubstrate { self = [super init]; if (self) { diff --git a/APCAppCore/APCAppCore/Startup/APCAppDelegate.h b/APCAppCore/APCAppCore/Startup/APCAppDelegate.h index 57e934ec..2bece508 100644 --- a/APCAppCore/APCAppCore/Startup/APCAppDelegate.h +++ b/APCAppCore/APCAppCore/Startup/APCAppDelegate.h @@ -32,7 +32,7 @@ // #import -#import "APCDataSubstrate.h" +#import "APCCoreDataSubstrate.h" #import "APCOnboarding.h" #import "APCPasscodeViewController.h" #import "APCProfileViewController.h" @@ -40,7 +40,7 @@ extern NSUInteger const kTheEntireDataModelOfTheApp; -@class APCDataSubstrate, APCDataMonitor, APCScheduler, APCOnboarding, APCPasscodeViewController, APCTasksReminderManager, APCPassiveDataCollector, APCFitnessAllocation; +@class APCDataMonitor, APCScheduler, APCOnboarding, APCPasscodeViewController, APCTasksReminderManager, APCPassiveDataCollector, APCFitnessAllocation; @interface APCAppDelegate : UIResponder @@ -48,7 +48,7 @@ extern NSUInteger const kTheEntireDataModelOfTheApp; @property (strong, nonatomic) UITabBarController *tabster; //APC Related Properties & Methods -@property (strong, nonatomic) APCDataSubstrate * dataSubstrate; +@property (strong, nonatomic) id dataSubstrate; @property (strong, nonatomic) APCDataMonitor * dataMonitor; @property (strong, nonatomic) APCScheduler * scheduler; @property (strong, nonatomic) APCTasksReminderManager * tasksReminder; diff --git a/APCAppCore/APCAppCore/Startup/APCAppDelegate.m b/APCAppCore/APCAppCore/Startup/APCAppDelegate.m index 3af97261..e6748c83 100644 --- a/APCAppCore/APCAppCore/Startup/APCAppDelegate.m +++ b/APCAppCore/APCAppCore/Startup/APCAppDelegate.m @@ -326,7 +326,7 @@ - (void) initializeAppleCoreStack //Check if persistent store (db.sqlite file) exists self.persistentStoreExistence = [self determineIfPeresistentStoreExists]; - self.dataSubstrate = [[APCDataSubstrate alloc] initWithPersistentStorePath:[[self applicationDocumentsDirectory] stringByAppendingPathComponent:self.initializationOptions[kDatabaseNameKey]] additionalModels: nil studyIdentifier:self.initializationOptions[kStudyIdentifierKey]]; + self.dataSubstrate = [[APCAppDataSubstrate alloc] initWithPersistentStorePath:[[self applicationDocumentsDirectory] stringByAppendingPathComponent:self.initializationOptions[kDatabaseNameKey]] additionalModels: nil studyIdentifier:self.initializationOptions[kStudyIdentifierKey]]; [self performMigrationAfterDataSubstrateFrom:[self obtainPreviousVersion] currentVersion:kTheEntireDataModelOfTheApp]; diff --git a/APCAppCore/APCAppCore/Startup/Migration/APCTasksAndSchedulesMigrationUtility.h b/APCAppCore/APCAppCore/Startup/Migration/APCTasksAndSchedulesMigrationUtility.h index a2cb670c..2dcb10b4 100644 --- a/APCAppCore/APCAppCore/Startup/Migration/APCTasksAndSchedulesMigrationUtility.h +++ b/APCAppCore/APCAppCore/Startup/Migration/APCTasksAndSchedulesMigrationUtility.h @@ -33,15 +33,16 @@ #import +#import "APCCoreDataSubstrate.h" #import "APCAppCore.h" @interface APCTasksAndSchedulesMigrationUtility : NSObject -@property (nonatomic, strong) NSDictionary *tasksAndSchedules; -@property (nonatomic, strong) NSString *tasksAndSchedulesFileName; -@property (strong, nonatomic) APCDataSubstrate *dataSubstrate; -@property (nonatomic) BOOL needsMigration; +@property (nonatomic, strong) NSDictionary *tasksAndSchedules; +@property (nonatomic, strong) NSString *tasksAndSchedulesFileName; +@property (strong, nonatomic) id dataSubstrate; +@property (nonatomic) BOOL needsMigration; - (instancetype)initWithFileName:(NSDictionary *)newTasksAndSchedules; diff --git a/APCAppCore/APCAppCore/UI/TasksAndSteps/APCBaseTaskViewController.m b/APCAppCore/APCAppCore/UI/TasksAndSteps/APCBaseTaskViewController.m index 5c644990..4ac649e3 100644 --- a/APCAppCore/APCAppCore/UI/TasksAndSteps/APCBaseTaskViewController.m +++ b/APCAppCore/APCAppCore/UI/TasksAndSteps/APCBaseTaskViewController.m @@ -224,7 +224,8 @@ - (void) processTaskResult - (void) storeInCoreDataWithFileName: (NSString *) fileName resultSummary: (NSString *) resultSummary { - NSManagedObjectContext * context = ((APCAppDelegate *)[UIApplication sharedApplication].delegate).dataSubstrate.mainContext; + id dataSubstrate = ((APCAppDelegate*)[UIApplication sharedApplication].delegate).dataSubstrate; + NSManagedObjectContext *context = dataSubstrate.mainContext; [self storeInCoreDataWithFileName: fileName resultSummary: resultSummary usingContext: context]; }