Good day, i am sending this question because i need help on SWIFT programming. I am working on a SWIFT project and I am looking there is one command to save information on device, "userDefaults" command, I need to add, i am using that command to allow end users to save some information entered in one window/form. My question, would you please let me know if i could pre-save or pre-load some saved information on my app, i am looking the userDefaults command creates a .plist document and there is all information saved (inside AppData/Library/preferences/. The purpose of this app is to capture some data but i want to show old data pre-loaded as soon the app is installed on iphone.
Today i am doing this trick but its taking too much time on Archive process even when my app it 5 mg data.
Trick ,
I am creating some functions like below:
func preLoadInfo001() {
preLoadInfo.append(["Number": "0001", "Day": "26", "Month": "9", "Year": "2023", "Data1": "1", "Data2": "2", "Data3": "2500", "Data4": "2700", "Data5": "2800", ])
.
.
.
preLoadInfo.append(["Number": "0200", "Day": "30", "Month": "9", "Year": "2023", "Data1": "10", "Data2": "20", "Data3": "2500", "Data40": "2700", "Data50": "28000", ])
}
func preLoadInfo002() {
preLoadInfo.append(["Number": "0001", "Day": "26", "Month": "9", "Year": "2023", "Data1": "1", "Data2": "2", "Data3": "2500", "Data4": "2700", "Data5": "2800", ])
.
.
.
preLoadInfo.append(["Number": "0200", "Day": "30", "Month": "9", "Year": "2023", "Data1": "10", "Data2": "20", "Data3": "2500", "Data40": "2700", "Data50": "28000", ])
}
func preLoadInfo003() {
preLoadInfo.append(["Number": "0001", "Day": "26", "Month": "9", "Year": "2023", "Data1": "1", "Data2": "2", "Data3": "2500", "Data4": "2700", "Data5": "2800", ])
.
.
.
preLoadInfo.append(["Number": "0200", "Day": "30", "Month": "9", "Year": "2023", "Data1": "10", "Data2": "20", "Data3": "2500", "Data40": "2700", "Data50": "28000", ])
}
I am having like 10 functions like this and i also created a button (that end user needs to hit to preload all information as soon as the installation is completed) with this function.
`func preLOAD(){
func preLoadInfo001()
func preLoadInfo002()
func preLoadInfo003()
.
.
.
func preLoadInfo020()
// Save all information on device
let userDefaults = UserDefaults.standard
userDefaults.set(mainInformation, forKey: "SavedInformation")
} // Save all information needed to use this app. `
My question is: Would you please let me know if exist a way to storage all this information on my App and as soon as end user installs the app then the .plist is created with all old information instead to request end user to push the button that is writing all information on device?
I do not know if a plist needs to be created with all old information and then find a way to install that on my final package app, or if i need to create an specific file , install that file on muy SWIFT project and then call that file as soon as end user open the app for first time.
Thank you in advance for all support.
I am expecting to know if exist a way to preload some information on my app package and then access all information by using userDefault command.