Swiftyinsta: ์‹คํŒจ(SwiftyInsta.GenericError.weakObjectReleased)

์— ๋งŒ๋“  2019๋…„ 09์›” 24์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: TheM4hd1/SwiftyInsta

ํฌ์ŠคํŠธ ๊ธฐ๋Šฅ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚ด๊ฐ€๋ฐ›๋Š” ๊ฒฐ๊ณผ๋Š” "failure(SwiftyInsta.GenericError.weakObjectReleased)"์ž…๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ๋ญ˜ ์ž˜๋ชปํ•˜๊ณ  ์žˆ์ฃ ? ์ด๊ฒƒ์ด ๋‹จ์ˆœํ•œ ์‹ค์ˆ˜๋ผ๋ฉด ์‚ฌ๊ณผ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ๋‚˜๋Š” ์—ฌ๊ธฐ์—์„œ ๋ชจ๋“  ์งˆ๋ฌธ์„ ๊ฒ€์ƒ‰ํ–ˆ๊ณ  ์ด๊ฒƒ์€ ๋‚ด๊ฐ€ ์–ป์€ ํ•œ, ์ปดํŒŒ์ผํ•˜์ง€๋งŒ ํ•ด๋‹น ์˜ค๋ฅ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

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

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

SwiftyInsta.GenericError.weakObjectReleased ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ APIHandler ๊ฐ€ ๊ฐ•๋ ฅํ•˜๊ฒŒ ์ฐธ์กฐ๋˜์ง€ ์•Š์„ ๋•Œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

๊ท€ํ•˜์˜ ์˜ˆ๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ์„ ์˜๋ฏธํ•˜๋Š” ๊ฒฝ์šฐ:

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

์™„๋ฃŒ ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ๋น„๋™๊ธฐ์ ์œผ๋กœ handler ๊ฐ€ ์ด๋ฏธ ํ•ด์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์ด๊ฒƒ์ด ์ž‘๋™ํ•˜๋ ค๋ฉด ์–ด๋”˜๊ฐ€์— "์ง€์†"ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด.

class SomeClass {
  let handler = APIHandler()

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

handler ๋Š” SomeClass ์ธ์Šคํ„ด์Šค๊ฐ€ ํ• ๋‹น๋  ๋•Œ๊นŒ์ง€ ํ• ๋‹น ํ•ด์ œ๋˜์ง€ ์•Š์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

๋ชจ๋“  3 ๋Œ“๊ธ€

SwiftyInsta.GenericError.weakObjectReleased ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ APIHandler ๊ฐ€ ๊ฐ•๋ ฅํ•˜๊ฒŒ ์ฐธ์กฐ๋˜์ง€ ์•Š์„ ๋•Œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

๊ท€ํ•˜์˜ ์˜ˆ๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ์„ ์˜๋ฏธํ•˜๋Š” ๊ฒฝ์šฐ:

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

์™„๋ฃŒ ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ๋น„๋™๊ธฐ์ ์œผ๋กœ handler ๊ฐ€ ์ด๋ฏธ ํ•ด์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์ด๊ฒƒ์ด ์ž‘๋™ํ•˜๋ ค๋ฉด ์–ด๋”˜๊ฐ€์— "์ง€์†"ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด.

class SomeClass {
  let handler = APIHandler()

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

handler ๋Š” SomeClass ์ธ์Šคํ„ด์Šค๊ฐ€ ํ• ๋‹น๋  ๋•Œ๊นŒ์ง€ ํ• ๋‹น ํ•ด์ œ๋˜์ง€ ์•Š์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์ด์ œ "failure(SwiftyInsta.GenericError.custom("Invalid response. 400"))"์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๋‚ด viewController์ž…๋‹ˆ๋‹ค. ์ด ์˜ค๋ฅ˜์— ๋Œ€ํ•œ ๋‚ด ์˜ค๋ฅ˜๋ฅผ ๋ณด์—ฌ์ฃผ์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ ์•„๋‹ˆ๋ฉด ์ด๋ฏธ์ง€๋ฅผ ๊ฒŒ์‹œํ•˜๋Š” ์ž‘์—… ๊ธฐ๋Šฅ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์ €์—๊ฒŒ ์—„์ฒญ๋‚œ ๋„์›€์ด ๋  ์ž˜๋ผ์„œ ๋ถ™์—ฌ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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)
        })    }


}

๊ท€ํ•˜์˜ ์ƒˆ ์˜ˆ์™ธ์— ๋Œ€ํ•œ ์ƒˆ ๋ฌธ์ œ๋ฅผ ์—ด์—ˆ์Šต๋‹ˆ๋‹ค.
์‹œ๊ฐ„๋‚˜๋Š”๋Œ€๋กœ ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค :muscle: @trentona
์ง€๊ธˆ๋ถ€ํ„ฐ #106์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰

๊ด€๋ จ ๋ฌธ์ œ

rmelnik7777 picture rmelnik7777  ยท  19์ฝ”๋ฉ˜ํŠธ

sbertix picture sbertix  ยท  8์ฝ”๋ฉ˜ํŠธ

effecttwins picture effecttwins  ยท  16์ฝ”๋ฉ˜ํŠธ

canaksoy picture canaksoy  ยท  6์ฝ”๋ฉ˜ํŠธ

reefer picture reefer  ยท  18์ฝ”๋ฉ˜ํŠธ