Fix a memory leak that happened every time you added a feed. Use a weak delegate to avoid a retain cycle.

This commit is contained in:
Brent Simmons 2017-12-13 21:19:12 -08:00
parent b04876185d
commit 859f479a89
1 changed files with 3 additions and 3 deletions

View File

@ -11,14 +11,14 @@ import RSParser
import RSWeb
import RSCore
public protocol FeedFinderDelegate {
public protocol FeedFinderDelegate: class {
func feedFinder(_: FeedFinder, didFindFeeds: Set<FeedSpecifier>)
}
public class FeedFinder {
fileprivate let delegate: FeedFinderDelegate
fileprivate weak var delegate: FeedFinderDelegate?
fileprivate var feedSpecifiers = [String: FeedSpecifier]()
fileprivate var didNotifyDelegate = false
@ -195,7 +195,7 @@ private extension FeedFinder {
func notifyDelegateIfNeeded() {
if !didNotifyDelegate {
delegate.feedFinder(self, didFindFeeds: Set(feedSpecifiers.values))
delegate?.feedFinder(self, didFindFeeds: Set(feedSpecifiers.values))
didNotifyDelegate = true
}
}