Skip to content

Commit

Permalink
Fix memory leak on WebViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadAlfhajri committed Dec 24, 2024
1 parent dc8b5bd commit d50b526
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class AuthenticationProvider: AuthenticationProviderProtocol {
func authenticate(fromViewController: UIViewController, URL: String, authentication: XenditAuthentication, completion: @escaping (XenditAuthentication?, XenditError?) -> Void) {
let webViewController = AuthenticationWebViewController(URL: URL)
webViewController.authentication = authentication
webViewController.authenticateCompletion = { updatedAuthentication, error in
webViewController.dismiss(animated: true, completion: nil)
webViewController.authenticateCompletion = { [weak webViewController] updatedAuthentication, error in
webViewController?.dismiss(animated: true, completion: nil)
completion(updatedAuthentication, error)
}
DispatchQueue.main.async {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Xendit/WebViewController/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class CardAuthenticationProvider: CardAuthenticationProviderProtocol {
let webViewController = WebViewController(URL: URL)

webViewController.token = authenticatedToken
webViewController.authenticateCompletion = { (token, error) -> Void in
webViewController.dismiss(animated: true, completion: nil)
webViewController.authenticateCompletion = { [weak webViewController] (token, error) -> Void in
webViewController?.dismiss(animated: true, completion: nil)
guard error == nil else {
return completion(nil, error)
}
Expand Down

0 comments on commit d50b526

Please sign in to comment.