From 72e250cdbdd88e4ba3265cd50641aea26832e705 Mon Sep 17 00:00:00 2001 From: Yimin Lin Date: Sat, 6 Oct 2018 00:07:51 +0800 Subject: [PATCH] Fixed a memory leak in YPImagePicker --- Source/YPImagePicker.swift | 4 ++-- Source/YPPickerVC.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/YPImagePicker.swift b/Source/YPImagePicker.swift index e35e5ea15..9eb1f8465 100644 --- a/Source/YPImagePicker.swift +++ b/Source/YPImagePicker.swift @@ -10,7 +10,7 @@ import UIKit import AVFoundation import Photos -public protocol YPImagePickerDelegate { +public protocol YPImagePickerDelegate: AnyObject { func noPhotos() } @@ -27,7 +27,7 @@ public class YPImagePicker: UINavigationController { public func didFinishPicking(completion: @escaping (_ items: [YPMediaItem], _ cancelled: Bool) -> Void) { _didFinishPicking = completion } - public var imagePickerDelegate: YPImagePickerDelegate? + public weak var imagePickerDelegate: YPImagePickerDelegate? public override var preferredStatusBarStyle: UIStatusBarStyle { return YPImagePickerConfiguration.shared.preferredStatusBarStyle diff --git a/Source/YPPickerVC.swift b/Source/YPPickerVC.swift index 3e2539d8f..5a28396cf 100644 --- a/Source/YPPickerVC.swift +++ b/Source/YPPickerVC.swift @@ -10,7 +10,7 @@ import Foundation import Stevia import Photos -protocol ImagePickerDelegate { +protocol ImagePickerDelegate: AnyObject { func noPhotos() } @@ -19,7 +19,7 @@ public class YPPickerVC: YPBottomPager, YPBottomPagerDelegate { let albumsManager = YPAlbumsManager() var shouldHideStatusBar = false var initialStatusBarHidden = false - var imagePickerDelegate: ImagePickerDelegate? + weak var imagePickerDelegate: ImagePickerDelegate? override public var prefersStatusBarHidden: Bool { return (shouldHideStatusBar || initialStatusBarHidden) && YPConfig.hidesStatusBar