Saturday, November 21, 2026
HomeiOS Developmentios - Async/Await: "out of vary error" when making an attempt to...

ios – Async/Await: “out of vary error” when making an attempt to entry array stuffed with downloaded pictures from firebase storage

[ad_1]

I attempted to obtain efficiently uploaded pictures to storage with the code:

 func retrieveAllPictures(helloid: String) async {
        
        let db = Firestore.firestore()
        var retrievedEventImages = [UIImage]()
        
        let end result = attempt? await db.assortment("occasions").doc(helloid).getDocument()
        allPictureIDs = (end result?.knowledge()!["pictures"] as? [String])!
        var picture = UIImage()
        
        
        for path in allPictureIDs {
            let storage = Storage.storage().reference()
            let fileRef = storage.little one(path)
            
  
      attempt? await fileRef.getData(maxSize: 1 * 1024 * 1024) { knowledge, error in
                if let error = error {
                    return
                } else {
                    picture = UIImage(knowledge: knowledge!)!
                   retrievedEventImages.append(picture)
                }
            }
    }
}

when making an attempt to debug the code, I see that retrievedEventImages is stuffed with the UIImages
nonetheless when making an attempt to entry the array at index 0 I get an out of vary error
perhaps somebody is aware of how you can repair it, any assistance is appreciated

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments