ios – The way to add a picture to firebase storage


I’m attempting to avoid wasting my consumer picture to firebase storage however I’m receiving this error

Worth of kind ‘Picture?’ has no member ‘jpegData’

How do I set my avatarImage to any knowledge to add my picture to firebase storage. I’m permitting the consumer to pick a picture after which save that picture to firebase storage. How do I arrange this code to repair my error to permit my consumer to add their picture

  @State personal var avatarItem: PhotosPickerItem?
    @State personal var avatarImage: Picture?

                PhotosPicker("Choose avatar", choice: $avatarItem, matching: .pictures)
                    if let avatarImage {
                            .body(width: 300, top: 300)
                .onChange(of: avatarItem) { _ in
                    Process {
                        if let knowledge = attempt? await avatarItem?.loadTransferable(kind: Knowledge.self) {
                            if let uiImage = UIImage(knowledge: knowledge) {
                                avatarImage = Picture(uiImage: uiImage)
    func AddFirebase() {
        var dict : Dictionary < String, Any> = [:
        let imageName = "NewPic"
        let storageRef =
        let imageReference =
        let selectedImage = avatarImage
        let imageData = selectedImage.jpegData(compressionQuality: 0.8)