Skip to content

Commit af1e084

Browse files
authored
Merge pull request #115 from UlricusR/dev
Merging from Dev
2 parents 267e432 + 2e896e8 commit af1e084

22 files changed

Lines changed: 340 additions & 364 deletions

EasyFPU.xcodeproj/project.pbxproj

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
1B0040582D254B7700D2FAF2 /* CustomButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0040572D254B7400D2FAF2 /* CustomButtons.swift */; };
11-
1B004A2D24BA3035001E362A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B004A2C24BA3035001E362A /* AppDelegate.swift */; };
12-
1B004A2F24BA3035001E362A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B004A2E24BA3035001E362A /* SceneDelegate.swift */; };
1311
1B004A3224BA3035001E362A /* EasyFPU.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1B004A3024BA3035001E362A /* EasyFPU.xcdatamodeld */; };
1412
1B004A3624BA3038001E362A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B004A3524BA3038001E362A /* Assets.xcassets */; };
1513
1B004A3924BA3038001E362A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B004A3824BA3038001E362A /* Preview Assets.xcassets */; };
@@ -82,10 +80,8 @@
8280
1BA1035C2CDBFF2D00776D15 /* AccessibilityIdentifierLeafModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA1035A2CDBFF2D00776D15 /* AccessibilityIdentifierLeafModifier.swift */; };
8381
1BA1035E2CDBFF6A00776D15 /* ParentAccessibilityBranchKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA1035D2CDBFF6A00776D15 /* ParentAccessibilityBranchKey.swift */; };
8482
1BA1041F2CE4B39400562BFD /* BusinessLogicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA1041E2CE4B39400562BFD /* BusinessLogicTests.swift */; };
85-
1BA2F762259F8AA9004300A4 /* ActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA2F761259F8AA9004300A4 /* ActivityView.swift */; };
8683
1BA963E02507DFC200375650 /* ComposedFoodItemExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA963DF2507DFC200375650 /* ComposedFoodItemExportView.swift */; };
8784
1BA963E4250807DD00375650 /* HelpMealExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA963E3250807DD00375650 /* HelpMealExportView.swift */; };
88-
1BA97D9029ABB5A5006D6754 /* ActivityIndicatorSpinner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BA97D8F29ABB5A5006D6754 /* ActivityIndicatorSpinner.swift */; };
8985
1BAD273D25495B4100A730FB /* FoodPreviewContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAD273C25495B4100A730FB /* FoodPreviewContent.swift */; };
9086
1BAD2740254A008000A730FB /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAD273F254A008000A730FB /* MainView.swift */; };
9187
1BAEE0862500C5FB00B4891F /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BAEE0852500C5FB00B4891F /* HealthKit.framework */; };
@@ -100,6 +96,8 @@
10096
1BC7524F254AFD5D001C4D27 /* FoodItemComposerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC7524E254AFD5D001C4D27 /* FoodItemComposerView.swift */; };
10197
1BCC1BEF2519036F00920264 /* CarbsRegime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BCC1BEE2519036F00920264 /* CarbsRegime.swift */; };
10298
1BD0693C254D97DD00B0E15A /* VariableAmountItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD0693B254D97DD00B0E15A /* VariableAmountItem.swift */; };
99+
1BD809A62D2AB9E5003A2A58 /* FoodDataDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD809A52D2AB9E5003A2A58 /* FoodDataDocument.swift */; };
100+
1BD809AE2D2AF4A5003A2A58 /* EasyFPUApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD809AD2D2AF49D003A2A58 /* EasyFPUApp.swift */; };
103101
1BDBE39C24FE384C00ED61F1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1BDBE39E24FE384C00ED61F1 /* InfoPlist.strings */; };
104102
1BEE525524D7611F00F10460 /* AbsorptionBlock+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BEE525324D7611F00F10460 /* AbsorptionBlock+CoreDataClass.swift */; };
105103
1BEE525624D7611F00F10460 /* AbsorptionBlock+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BEE525424D7611F00F10460 /* AbsorptionBlock+CoreDataProperties.swift */; };
@@ -132,8 +130,6 @@
132130
/* Begin PBXFileReference section */
133131
1B0040572D254B7400D2FAF2 /* CustomButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomButtons.swift; sourceTree = "<group>"; };
134132
1B004A2924BA3035001E362A /* EasyFPU.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EasyFPU.app; sourceTree = BUILT_PRODUCTS_DIR; };
135-
1B004A2C24BA3035001E362A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
136-
1B004A2E24BA3035001E362A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
137133
1B004A3124BA3035001E362A /* EasyFPU.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = EasyFPU.xcdatamodel; sourceTree = "<group>"; };
138134
1B004A3524BA3038001E362A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
139135
1B004A3824BA3038001E362A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
@@ -206,10 +202,8 @@
206202
1BA1035A2CDBFF2D00776D15 /* AccessibilityIdentifierLeafModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityIdentifierLeafModifier.swift; sourceTree = "<group>"; };
207203
1BA1035D2CDBFF6A00776D15 /* ParentAccessibilityBranchKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParentAccessibilityBranchKey.swift; sourceTree = "<group>"; };
208204
1BA1041E2CE4B39400562BFD /* BusinessLogicTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BusinessLogicTests.swift; sourceTree = "<group>"; };
209-
1BA2F761259F8AA9004300A4 /* ActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityView.swift; sourceTree = "<group>"; };
210205
1BA963DF2507DFC200375650 /* ComposedFoodItemExportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposedFoodItemExportView.swift; sourceTree = "<group>"; };
211206
1BA963E3250807DD00375650 /* HelpMealExportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpMealExportView.swift; sourceTree = "<group>"; };
212-
1BA97D8F29ABB5A5006D6754 /* ActivityIndicatorSpinner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivityIndicatorSpinner.swift; sourceTree = "<group>"; };
213207
1BAD273C25495B4100A730FB /* FoodPreviewContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodPreviewContent.swift; sourceTree = "<group>"; };
214208
1BAD273F254A008000A730FB /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
215209
1BAEE0852500C5FB00B4891F /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
@@ -225,6 +219,8 @@
225219
1BC9691F2CD7B8AE00A35ACA /* EasyFPUUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EasyFPUUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
226220
1BCC1BEE2519036F00920264 /* CarbsRegime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbsRegime.swift; sourceTree = "<group>"; };
227221
1BD0693B254D97DD00B0E15A /* VariableAmountItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VariableAmountItem.swift; sourceTree = "<group>"; };
222+
1BD809A52D2AB9E5003A2A58 /* FoodDataDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodDataDocument.swift; sourceTree = "<group>"; };
223+
1BD809AD2D2AF49D003A2A58 /* EasyFPUApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EasyFPUApp.swift; sourceTree = "<group>"; };
228224
1BDBE39D24FE384C00ED61F1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
229225
1BDBE39F24FE385F00ED61F1 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
230226
1BE506F12A840DE60087DD59 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
@@ -308,9 +304,8 @@
308304
1BFDFA22250A1D9B00379EB3 /* HealthKit */,
309305
1BAEE0892500E15600B4891F /* UIHelpers */,
310306
1B004A4324BA3383001E362A /* EasyFPU.entitlements */,
311-
1B004A2C24BA3035001E362A /* AppDelegate.swift */,
307+
1BD809AD2D2AF49D003A2A58 /* EasyFPUApp.swift */,
312308
1B4329C02CBEB19F00C478C3 /* CoreDataStack.swift */,
313-
1B004A2E24BA3035001E362A /* SceneDelegate.swift */,
314309
1BA104202CE4B41900562BFD /* Views */,
315310
1B004A3524BA3038001E362A /* Assets.xcassets */,
316311
1B004A3D24BA3038001E362A /* Info.plist */,
@@ -382,6 +377,7 @@
382377
1B6106B924D93325001F2284 /* Helpers */ = {
383378
isa = PBXGroup;
384379
children = (
380+
1BD809A52D2AB9E5003A2A58 /* FoodDataDocument.swift */,
385381
1B6106BA24D93346001F2284 /* DataHelper.swift */,
386382
1B9723EC2508AC5C00E606A7 /* UserSettings.swift */,
387383
1B12690C2A8E52B40047B1F5 /* DataWrapper.swift */,
@@ -488,9 +484,7 @@
488484
1B0040572D254B7400D2FAF2 /* CustomButtons.swift */,
489485
1BBFA9A22523B2FE00FB78D3 /* CustomViews.swift */,
490486
1B0868B1254F0D3E005953CC /* NotificationView.swift */,
491-
1BA97D8F29ABB5A5006D6754 /* ActivityIndicatorSpinner.swift */,
492487
1BF21B062552813000590068 /* ActivityIndicatorDynamicText.swift */,
493-
1BA2F761259F8AA9004300A4 /* ActivityView.swift */,
494488
);
495489
path = UIHelpers;
496490
sourceTree = "<group>";
@@ -668,6 +662,7 @@
668662
1BCC1BEF2519036F00920264 /* CarbsRegime.swift in Sources */,
669663
1BF21B072552813000590068 /* ActivityIndicatorDynamicText.swift in Sources */,
670664
1BD0693C254D97DD00B0E15A /* VariableAmountItem.swift in Sources */,
665+
1BD809AE2D2AF4A5003A2A58 /* EasyFPUApp.swift in Sources */,
671666
1B6106BB24D93346001F2284 /* DataHelper.swift in Sources */,
672667
1B0868AB254EDDC0005953CC /* FoodItemListView.swift in Sources */,
673668
1BAD273D25495B4100A730FB /* FoodPreviewContent.swift in Sources */,
@@ -684,7 +679,6 @@
684679
1B8A4A9224CABA5800542212 /* TypicalAmountViewModel.swift in Sources */,
685680
1BFDFA24250A1DBB00379EB3 /* CarbsRegimeCalculator.swift in Sources */,
686681
1B816B4F2CAB2FCF008670B5 /* RecipeListView.swift in Sources */,
687-
1B004A2D24BA3035001E362A /* AppDelegate.swift in Sources */,
688682
1B8A4A9024CABA2100542212 /* FoodItemViewModel.swift in Sources */,
689683
1BF1A15A251AA1F8001E561C /* ComposedFoodItemSugarsView.swift in Sources */,
690684
1BC75243254AF786001C4D27 /* ComposedFoodItemViewModel.swift in Sources */,
@@ -713,7 +707,6 @@
713707
1B004A3224BA3035001E362A /* EasyFPU.xcdatamodeld in Sources */,
714708
1B24AD6C24BE38E800F3A100 /* FoodItemSelector.swift in Sources */,
715709
1B0CE2BA250663B5008B04E3 /* HealthDataHelper.swift in Sources */,
716-
1BA97D9029ABB5A5006D6754 /* ActivityIndicatorSpinner.swift in Sources */,
717710
1B3EEB16253368B3004C110A /* HealthExportCarbsPreviewChart.swift in Sources */,
718711
1B18844A253B336500B671A2 /* FoodDatabaseEntry+FoodDatabaseImage.swift in Sources */,
719712
1B377A6624FA5A44005AC5C6 /* DisclaimerView.swift in Sources */,
@@ -731,12 +724,11 @@
731724
1B870FC124C9A32E00183C9F /* ComposedFoodItemEvaluationView.swift in Sources */,
732725
1BB9BDA22CDD56DB0043B465 /* AbsorptionBlockSettingsView.swift in Sources */,
733726
1B5B91062CA9B6B200135569 /* CountryPickerView.swift in Sources */,
734-
1B004A2F24BA3035001E362A /* SceneDelegate.swift in Sources */,
735727
1B25D483253DB0A900848C2A /* FoodSearch.swift in Sources */,
736-
1BA2F762259F8AA9004300A4 /* ActivityView.swift in Sources */,
737728
1B3CEB9B24D32D38001D64DA /* TherapySettingsEditor.swift in Sources */,
738729
1B3CEB9D24D33CC8001D64DA /* AbsorptionSchemeViewModel.swift in Sources */,
739730
1B5CA4F52D062A1F002AD0A8 /* FoodMaintenanceListView.swift in Sources */,
731+
1BD809A62D2AB9E5003A2A58 /* FoodDataDocument.swift in Sources */,
740732
1BA1035B2CDBFF2D00776D15 /* AccessibilityIdentifierBranchModifier.swift in Sources */,
741733
1BA1035C2CDBFF2D00776D15 /* AccessibilityIdentifierLeafModifier.swift in Sources */,
742734
1B6867DF24FD00F40057EC6A /* HelpViewProductsList.swift in Sources */,
@@ -933,7 +925,7 @@
933925
CLANG_ENABLE_MODULES = YES;
934926
CODE_SIGN_ENTITLEMENTS = EasyFPU/EasyFPU.entitlements;
935927
CODE_SIGN_STYLE = Automatic;
936-
CURRENT_PROJECT_VERSION = 1;
928+
CURRENT_PROJECT_VERSION = 2;
937929
DEVELOPMENT_ASSET_PATHS = "\"EasyFPU/Preview Content\"";
938930
DEVELOPMENT_TEAM = Q4HRNRLV9A;
939931
ENABLE_PREVIEWS = YES;
@@ -966,7 +958,7 @@
966958
CLANG_ENABLE_MODULES = YES;
967959
CODE_SIGN_ENTITLEMENTS = EasyFPU/EasyFPU.entitlements;
968960
CODE_SIGN_STYLE = Automatic;
969-
CURRENT_PROJECT_VERSION = 1;
961+
CURRENT_PROJECT_VERSION = 2;
970962
DEVELOPMENT_ASSET_PATHS = "\"EasyFPU/Preview Content\"";
971963
DEVELOPMENT_TEAM = Q4HRNRLV9A;
972964
ENABLE_PREVIEWS = YES;

EasyFPU/AppDelegate.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

EasyFPU/EasyFPUApp.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// EasyFPUApp.swift
3+
// EasyFPU
4+
//
5+
// Created by Ulrich Rüth on 05/01/2025.
6+
// Copyright © 2025 Ulrich Rüth. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
@main
12+
struct EasyFPUApp: App {
13+
let context = CoreDataStack.shared.persistentContainer.viewContext
14+
15+
var body: some Scene {
16+
WindowGroup {
17+
MainView()
18+
.environment(\.managedObjectContext, context)
19+
}
20+
}
21+
}

EasyFPU/Helpers/DataHelper.swift

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -28,67 +28,38 @@ enum InvalidNumberError: Error {
2828
}
2929
}
3030

31+
enum ImportExportError: Error {
32+
case wrongFileExtension
33+
case noFileAccess
34+
}
35+
3136
struct ImportData: Identifiable {
3237
var id = UUID()
33-
let foodItemVMsToBeImported: [FoodItemViewModel]
38+
let foodItemVMsToBeImported: [FoodItemViewModel]?
3439
let composedFoodItemVMsToBeImported: [ComposedFoodItemViewModel]?
35-
}
36-
37-
struct ExportJSONDocument: FileDocument {
38-
static var readableContentTypes: [UTType] {
39-
[UTType.json]
40-
}
41-
42-
private var jsonContent: Data
4340

44-
/// Creates an empty Data object for jsonContent, only required for the .fileExport modifier
45-
init() {
46-
jsonContent = Data()
41+
/// Returns the number of FoodItemViewModels and ComposedFoodItemViewModels.
42+
/// - Returns: The number of FoodItemViewModels and ComposedFoodItemViewModels (in this order).
43+
func countItems() -> (Int, Int) {
44+
(
45+
foodItemVMsToBeImported == nil ? 0 : foodItemVMsToBeImported!.count,
46+
composedFoodItemVMsToBeImported == nil ? 0 : composedFoodItemVMsToBeImported!.count
47+
)
4748
}
4849

49-
/// Creates a JSON Data object with all FoodItems and ComposedFoodItems
50-
/// - Parameter errorMessage: The error message if initialization fails
51-
init?(errorMessage: inout String) {
52-
// Get Core Data FoodItems and load them into FoodItemViewModels
53-
let cdFoodItems = FoodItem.fetchAll()
54-
var foodItems = [FoodItemViewModel]()
55-
for cdFoodItem in cdFoodItems {
56-
foodItems.append(FoodItemViewModel(from: cdFoodItem))
57-
}
58-
59-
// Get Core Data ComposedFoodItems and load them into ComposedFoodItemViewModels
60-
let cdComposedFoodItems = ComposedFoodItem.fetchAll()
61-
var composedFoodItems = [ComposedFoodItemViewModel]()
62-
for cdComposedFoodItem in cdComposedFoodItems {
63-
composedFoodItems.append(ComposedFoodItemViewModel(from: cdComposedFoodItem))
50+
func save() {
51+
if let foodItemVMs = foodItemVMsToBeImported {
52+
for foodItemVM in foodItemVMs {
53+
foodItemVM.save()
54+
}
6455
}
6556

66-
// Prepare the DataWrapper
67-
let dataWrapper = DataWrapper(dataModelVersion: .version2, foodItemVMs: foodItems, composedFoodItemVMs: composedFoodItems)
68-
69-
// Encode
70-
do {
71-
let encoder = JSONEncoder()
72-
encoder.outputFormatting = .prettyPrinted
73-
jsonContent = try encoder.encode(dataWrapper)
74-
} catch {
75-
errorMessage = error.localizedDescription
76-
return nil
77-
}
78-
}
79-
80-
init(configuration: ReadConfiguration) throws {
81-
if let data = configuration.file.regularFileContents {
82-
jsonContent = data
83-
} else {
84-
// Create an empty Data object
85-
jsonContent = Data()
57+
if let composedFoodItemVMs = composedFoodItemVMsToBeImported {
58+
for composedFoodItemVM in composedFoodItemVMs {
59+
_ = composedFoodItemVM.save()
60+
}
8661
}
8762
}
88-
89-
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
90-
return FileWrapper(regularFileWithContents: jsonContent)
91-
}
9263
}
9364

9465
struct DataHelper {
@@ -124,7 +95,27 @@ struct DataHelper {
12495

12596
// MARK: - Importing and exporting food items as JSON
12697

127-
static func importFoodItems(
98+
/// Stores all FoodItems and ComposedFoodItems in an array.
99+
/// - Returns: A two-dimensional array with FoodItemViewModels and ComposedFoodItemViewModels (in that order).
100+
static func getAllFoodData() -> [[Any]] {
101+
// Get Core Data FoodItems and load them into FoodItemViewModels
102+
let cdFoodItems = FoodItem.fetchAll()
103+
var foodItems = [FoodItemViewModel]()
104+
for cdFoodItem in cdFoodItems {
105+
foodItems.append(FoodItemViewModel(from: cdFoodItem))
106+
}
107+
108+
// Get Core Data ComposedFoodItems and load them into ComposedFoodItemViewModels
109+
let cdComposedFoodItems = ComposedFoodItem.fetchAll()
110+
var composedFoodItems = [ComposedFoodItemViewModel]()
111+
for cdComposedFoodItem in cdComposedFoodItems {
112+
composedFoodItems.append(ComposedFoodItemViewModel(from: cdComposedFoodItem))
113+
}
114+
115+
return [foodItems, composedFoodItems]
116+
}
117+
118+
static func importFoodData(
128119
_ file: URL,
129120
errorMessage: inout String
130121
) -> ImportData? {
@@ -148,6 +139,11 @@ struct DataHelper {
148139
return nil
149140
}
150141

142+
// Decode JSON
143+
return decodeFoodData(jsonData: jsonData, errorMessage: &errorMessage)
144+
}
145+
146+
static func decodeFoodData(jsonData: Data, errorMessage: inout String) -> ImportData? {
151147
// Decode JSON
152148
let decoder = JSONDecoder()
153149

0 commit comments

Comments
 (0)