Add error handling to loading unexisting files
This commit is contained in:
parent
8f4ecf0cb2
commit
fba4ed65e9
@ -485,7 +485,7 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"RippleChat/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B5S58UWR64;
|
||||
DEVELOPMENT_TEAM = GN2B48NJ47;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Allow for bluetooth use";
|
||||
@ -500,7 +500,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = unibas.inetsec.RippleChat;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = unibas.inetsec.RippleChat1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
@ -516,7 +516,7 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"RippleChat/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B5S58UWR64;
|
||||
DEVELOPMENT_TEAM = GN2B48NJ47;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Allow for bluetooth use";
|
||||
@ -531,7 +531,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = unibas.inetsec.RippleChat;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = unibas.inetsec.RippleChat1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
|
||||
@ -54,7 +54,9 @@ class DataStore: ObservableObject {
|
||||
func loadPersonalID() async throws {
|
||||
let task = Task<String, Error> {
|
||||
let fileURL = try self.fileURL(for: "personalID")
|
||||
let data = try Data(contentsOf: fileURL)
|
||||
guard let data = try? Data(contentsOf: fileURL) else {
|
||||
return ""
|
||||
}
|
||||
let personalID = try JSONDecoder().decode(String.self, from: data)
|
||||
return personalID
|
||||
}
|
||||
@ -65,7 +67,9 @@ class DataStore: ObservableObject {
|
||||
func loadFriends() async throws {
|
||||
let task = Task<[String:Int], Error> {
|
||||
let fileURL = try self.fileURL(for: "friends")
|
||||
let data = try Data(contentsOf: fileURL)
|
||||
guard let data = try? Data(contentsOf: fileURL) else {
|
||||
return [:]
|
||||
}
|
||||
let friends = try JSONDecoder().decode([String:Int].self, from: data)
|
||||
return friends
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user