Im trying to get the function deletePhoto() to delete the previous UID. the deletePhoto() function works perfectly the problem is that uploadPhoto() is changing prevUni before the delete photo function is run. Is there anyway I can work around this?
<code> Task {
if let photosPickerItem,
let data = try await photosPickerItem.loadTransferable(type: Data.self) {
if let image = UIImage(data: data) {
avatarImage = image
}
}
await deletePhoto()
print("deleted: (aViewModel.currentUser?.prevUni ?? "") ")
uploadPhoto()
print("uploaded: (aViewModel.currentUser?.prevUni ?? "") ")
}
</code>
<code> Task {
if let photosPickerItem,
let data = try await photosPickerItem.loadTransferable(type: Data.self) {
if let image = UIImage(data: data) {
avatarImage = image
}
}
await deletePhoto()
print("deleted: (aViewModel.currentUser?.prevUni ?? "") ")
uploadPhoto()
print("uploaded: (aViewModel.currentUser?.prevUni ?? "") ")
}
</code>
Task {
if let photosPickerItem,
let data = try await photosPickerItem.loadTransferable(type: Data.self) {
if let image = UIImage(data: data) {
avatarImage = image
}
}
await deletePhoto()
print("deleted: (aViewModel.currentUser?.prevUni ?? "") ")
uploadPhoto()
print("uploaded: (aViewModel.currentUser?.prevUni ?? "") ")
}
Ive tried a numerous amount of things this was ultimately the last thing I could come up with.
New contributor
dex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.