Swiftyinsta: falla (SwiftyInsta.GenericError.weakObjectReleased)

Creado en 24 sept. 2019  ·  3Comentarios  ·  Fuente: TheM4hd1/SwiftyInsta

Tengo dificultades con la función de publicación. El resultado que recibo es "error (SwiftyInsta.GenericError.weakObjectReleased)"

¿Qué estoy haciendo mal? Mis disculpas si esto es un simple error. Busqué en todas las preguntas aquí y esto es todo lo que pude, se compila pero devuelve ese error.

func uploadImage() {

    let img = imageView.image!
    let myCaption = "Sample Caption"

      guard let key = UserDefaults.standard.string(forKey: "current.account") else { return print("`key` not found.") }

    guard let cache = Authentication.Response.persisted(with: key) else { return print("`Authentication.Response` not found.") }

        let handler = APIHandler()
            handler.authenticate(with: .cache(cache)) { _ in

        let img1: Upload.Picture = Upload.Picture(image: img, caption: myCaption, size: CGSize(width: 30,height: 30) )



        handler.media.upload(photo: img1, completionHandler: { (result) in
print(result)

})

}

    }
help wanted

Comentario más útil

SwiftyInsta.GenericError.weakObjectReleased generalmente se llama cuando APIHandler no tiene una referencia fuerte.

Si su ejemplo significa algo como esto:

func someFunction(cache: Authentication.Response) {
  let handler = APIHandler()
  handler.authenticate(with: .cache(cache)) { _ in
  }
}

Una vez que se llama al controlador de finalización, de forma asincrónica, su handler ya se ha liberado.
Para que esto funcione, necesita "persistir" en alguna parte. Por ejemplo.

class SomeClass {
  let handler = APIHandler()

  func someFunction(cache: Authentication.Response) {
    handler.authenticate(with: .cache(cache)) { _ in }
  }
}

Lo que significa que handler no se desasignará hasta que su instancia SomeClass sea.

Todos 3 comentarios

SwiftyInsta.GenericError.weakObjectReleased generalmente se llama cuando APIHandler no tiene una referencia fuerte.

Si su ejemplo significa algo como esto:

func someFunction(cache: Authentication.Response) {
  let handler = APIHandler()
  handler.authenticate(with: .cache(cache)) { _ in
  }
}

Una vez que se llama al controlador de finalización, de forma asincrónica, su handler ya se ha liberado.
Para que esto funcione, necesita "persistir" en alguna parte. Por ejemplo.

class SomeClass {
  let handler = APIHandler()

  func someFunction(cache: Authentication.Response) {
    handler.authenticate(with: .cache(cache)) { _ in }
  }
}

Lo que significa que handler no se desasignará hasta que su instancia SomeClass sea.

Gracias, ahora está obteniendo "falla (SwiftyInsta.GenericError.custom (" Respuesta no válida. 400 "))". Este es mi viewController, ¿podría mostrarme mis errores en este o si tiene una función de trabajo para publicar una imagen que podría cortar y pegar para mí que me ayudaría enormemente? No tengo idea de dónde está yendo mal.

import UIKit
import SwiftyInsta
class DeploymentViewController: UIViewController {

    let handler = APIHandler()
    <strong i="6">@IBOutlet</strong> weak var sampleImage: UIImageView!


        override func viewDidLoad() {
                super.viewDidLoad()

        }

   <strong i="7">@IBAction</strong> func test(_ sender: Any) {


        guard let key = UserDefaults.standard.string(forKey: "current.account") else { return 
print("`key` not found.") }

        guard let cache = Authentication.Response.persisted(with: key) else { return 
print("`Authentication.Response` not found.") }
            handler.authenticate(with: .cache(cache)) { _ in    }

        let img1: Upload.Picture = Upload.Picture(image: self.sampleImage.image!, caption: 
"sampleText", size: CGSize(width: 1080,height: 1080) )


            self.handler.media.upload(photo: img1, completionHandler: { (result) in



            print(result)
        })    }


}

Abrí un nuevo problema para su nueva excepción.
Lo investigaré tan pronto como tenga algo de tiempo: músculo: @trentona
Por favor, haga referencia al # 106 de ahora en adelante.

¿Fue útil esta página
0 / 5 - 0 calificaciones

Temas relacionados

sbertix picture sbertix  ·  8Comentarios

biox86 picture biox86  ·  12Comentarios

effecttwins picture effecttwins  ·  16Comentarios

anonrig picture anonrig  ·  3Comentarios

canaksoy picture canaksoy  ·  6Comentarios