mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 12:30:29 +00:00
Check for Error
This commit is contained in:
parent
8c2a104fdb
commit
4f670fa169
1 changed files with 5 additions and 5 deletions
|
|
@ -147,17 +147,17 @@ class InstalledAppsViewModel: ObservableObject {
|
|||
return
|
||||
}
|
||||
|
||||
if output.hasPrefix("{\"error\":") {
|
||||
self.apps = [:]
|
||||
}
|
||||
|
||||
print(output)
|
||||
|
||||
// Decode the JSON into a Swift dictionary
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let apps = try decoder.decode([String: String].self, from: jsonData)
|
||||
self.apps = apps
|
||||
if let app = apps.first, app.key == "error" {
|
||||
self.apps = [:]
|
||||
} else {
|
||||
self.apps = apps
|
||||
}
|
||||
return
|
||||
} catch {
|
||||
print("Error: Failed to decode JSON - \(error)")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue