Bonjour à tous,
j’obtiens cette erreur sur mon projet :
Thread 1: EXC_BAD_ACCESS (code=1, address=0xa3a3a3a3a3a3a3b3)
, erreur que je n’avais pas et je ne vois pas ce qu’il peut se passer!
La seule chose que je vois c’est que l’erreur intervient quand j’essaie de récupérer mon utilisateur courant depuis directus (pas de soucis sur la version flotter, juste la version IOS)
Je n’ai rien changé de spécial et j’ai beau debugger je trouve rien, si quelqu’un a une idée.
L’erreur :
Permutation`static PermutationApp.$main():
0x102fbfb60 <+0>: stp x20, x19, [sp, #-0x20]!
0x102fbfb64 <+4>: stp x29, x30, [sp, #0x10]
0x102fbfb68 <+8>: add x29, sp, #0x10
0x102fbfb6c <+12>: mov x0, #0x0
0x102fbfb70 <+16>: bl 0x102fbe30c ; type metadata accessor for Permutation.PermutationApp at <compiler-generated>
0x102fbfb74 <+20>: mov x20, x0
0x102fbfb78 <+24>: bl 0x102fbfb94 ; lazy protocol witness table accessor for type Permutation.PermutationApp and conformance Permutation.PermutationApp : SwiftUI.App in Permutation at <compiler-generated>
0x102fbfb7c <+28>: mov x1, x0
0x102fbfb80 <+32>: mov x0, x20
0x102fbfb84 <+36>: bl 0x103193380 ; symbol stub for: static SwiftUI.App.main() -> ()
-> 0x102fbfb88 <+40>: ldp x29, x30, [sp, #0x10]
0x102fbfb8c <+44>: ldp x20, x19, [sp], #0x20
0x102fbfb90 <+48>: ret
ma fonction :
@MainActor
private func getCurrentUser(token:Token) async -> CurrentUser? {
var currentUser:CurrentUser? = nil
guard let url = URL(string:"https://********/users/me?fields=*,station.*,alerts.id,alerts.alertStation,alerts.alertDepartment,alerts.alertCity,permutations.id,permutations.user_created.phone,permutations.user_created.sharePhone,user_created.contactMail,permutations.user_created.shareEmail,permutations.user_created.id,permutations.user_created.first_name,permutations.user_created.last_name,permutations.user_created.email,permutations.user_created.avatar,permutations.user_created.station.id,permutations.user_created.station.service,permutations.user_created.station.department,permutations.user_created.grade,permutations.user_created.deviceToken,permutations.user_created.iosOrAndroid,,permutations.user_created.location") else {return nil}
let session = URLSession.shared
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("Bearer \(token.access_token)", forHTTPHeaderField: "Authorization")
do {
let (data, _) = try await session.data(for: request)
if let decodedResponse = try? JSONDecoder().decode(CurrentUserJson.self, from: data) {
currentUser = decodedResponse.data
let deviceToken = UserDefaults.standard.string(forKey: "deviceToken")
if currentUser?.deviceToken == nil || currentUser?.deviceToken != deviceToken {
await updateCurrentUser(token: token, deviceToken: deviceToken)
// currentUser?.deviceToken = deviceToken
}
if currentUser?.iosOrAndroid == nil || currentUser?.iosOrAndroid != "IOS" {
await updateCurrentUser(token: token, iosOrAndroid: "IOS")
// currentUser?.iosOrAndroid = "IOS"
}
} else {
print("Impossible de charger l'utilisateur actuel")
}
} catch let jsonError as NSError {
print("JSON decode failed: \(jsonError.localizedDescription)")
}
return currentUser
}