From b7f8bce693c1b8162407a6b24455c7267b3263e4 Mon Sep 17 00:00:00 2001 From: bryanjclark Date: Thu, 14 Jan 2021 10:08:51 -0800 Subject: [PATCH] Change delegate properties to be unowned To address concerns in #127 --- SwiftTweaks/StringOptionViewController.swift | 4 ++-- SwiftTweaks/TweakCollectionViewController.swift | 4 ++-- SwiftTweaks/TweakColorCell.swift | 4 ++-- SwiftTweaks/TweakColorEditViewController.swift | 4 ++-- SwiftTweaks/TweaksCollectionsListViewController.swift | 5 ++--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/SwiftTweaks/StringOptionViewController.swift b/SwiftTweaks/StringOptionViewController.swift index d5add75..6a3dc37 100644 --- a/SwiftTweaks/StringOptionViewController.swift +++ b/SwiftTweaks/StringOptionViewController.swift @@ -9,7 +9,7 @@ import Foundation import UIKit -internal protocol StringOptionViewControllerDelegate { +internal protocol StringOptionViewControllerDelegate: class { func stringOptionViewControllerDidPressDismissButton(_ tweakSelectionViewController: StringOptionViewController) } @@ -17,7 +17,7 @@ internal protocol StringOptionViewControllerDelegate { internal class StringOptionViewController: UITableViewController { fileprivate let tweak: Tweak fileprivate let tweakStore: TweakStore - fileprivate let delegate: StringOptionViewControllerDelegate + fileprivate unowned var delegate: StringOptionViewControllerDelegate fileprivate var currentOption: String { didSet { diff --git a/SwiftTweaks/TweakCollectionViewController.swift b/SwiftTweaks/TweakCollectionViewController.swift index d023f2f..1e274d3 100644 --- a/SwiftTweaks/TweakCollectionViewController.swift +++ b/SwiftTweaks/TweakCollectionViewController.swift @@ -8,7 +8,7 @@ import UIKit -internal protocol TweakCollectionViewControllerDelegate { +internal protocol TweakCollectionViewControllerDelegate: class { func tweakCollectionViewControllerDidPressDismissButton(_ tweakCollectionViewController: TweakCollectionViewController) func tweakCollectionViewController(_ tweakCollectionViewController: TweakCollectionViewController, didTapFloatingTweakGroupButtonForTweakGroup tweakGroup: TweakGroup) } @@ -18,7 +18,7 @@ internal final class TweakCollectionViewController: UIViewController { fileprivate let tweakCollection: TweakCollection fileprivate let tweakStore: TweakStore - fileprivate let delegate: TweakCollectionViewControllerDelegate + fileprivate unowned var delegate: TweakCollectionViewControllerDelegate fileprivate let tableView: UITableView = { let tableView = UITableView(frame: CGRect.zero, style: .grouped) diff --git a/SwiftTweaks/TweakColorCell.swift b/SwiftTweaks/TweakColorCell.swift index 136cfca..2442289 100644 --- a/SwiftTweaks/TweakColorCell.swift +++ b/SwiftTweaks/TweakColorCell.swift @@ -8,7 +8,7 @@ import UIKit -internal protocol TweakColorCellDelegate { +internal protocol TweakColorCellDelegate: class { func tweakColorCellDidChangeValue(_ cell: TweakColorCell) } @@ -16,7 +16,7 @@ internal protocol TweakColorCellDelegate { internal final class TweakColorCell: UITableViewCell { internal static let cellHeight: CGFloat = 50 - internal var delegate: TweakColorCellDelegate? + internal unowned var delegate: TweakColorCellDelegate? internal var viewData: ColorComponent? { didSet { diff --git a/SwiftTweaks/TweakColorEditViewController.swift b/SwiftTweaks/TweakColorEditViewController.swift index e70286c..1c896bb 100644 --- a/SwiftTweaks/TweakColorEditViewController.swift +++ b/SwiftTweaks/TweakColorEditViewController.swift @@ -8,7 +8,7 @@ import UIKit -internal protocol TweakColorEditViewControllerDelegate { +internal protocol TweakColorEditViewControllerDelegate: class { func tweakColorEditViewControllerDidPressDismissButton(_ tweakColorEditViewController: TweakColorEditViewController) } @@ -16,7 +16,7 @@ internal protocol TweakColorEditViewControllerDelegate { internal final class TweakColorEditViewController: UIViewController { private let tweak: Tweak private let tweakStore: TweakStore - private let delegate: TweakColorEditViewControllerDelegate + private unowned var delegate: TweakColorEditViewControllerDelegate fileprivate var viewData: ColorRepresentation { didSet { diff --git a/SwiftTweaks/TweaksCollectionsListViewController.swift b/SwiftTweaks/TweaksCollectionsListViewController.swift index 81ae01f..a651f07 100644 --- a/SwiftTweaks/TweaksCollectionsListViewController.swift +++ b/SwiftTweaks/TweaksCollectionsListViewController.swift @@ -8,7 +8,7 @@ import UIKit -internal protocol TweaksCollectionsListViewControllerDelegate { +internal protocol TweaksCollectionsListViewControllerDelegate: class { func tweaksCollectionsListViewControllerDidTapDismissButton(_ tweaksCollectionsListViewController: TweaksCollectionsListViewController) func tweaksCollectionsListViewControllerDidTapShareButton(_ tweaksCollectionsListViewController: TweaksCollectionsListViewController, shareButton: UIBarButtonItem) func tweakCollectionListViewController(_ tweakCollectionViewController: TweaksCollectionsListViewController, didTapFloatingTweakGroupButtonForTweakGroup tweakGroup: TweakGroup) @@ -19,8 +19,7 @@ internal final class TweaksCollectionsListViewController: UIViewController { private let tableView: UITableView fileprivate let tweakStore: TweakStore - fileprivate let delegate: TweaksCollectionsListViewControllerDelegate - + fileprivate unowned var delegate: TweaksCollectionsListViewControllerDelegate // MARK: Init