forked from shadowfacts/Tusker
Fix retain cycles with TuskerNavigationDelegate
TuskerNavigationDelegate is now class-bound and only weak references to it are stored.
This commit is contained in:
parent
c45dd99088
commit
32e89f2c16
|
@ -8,7 +8,7 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
protocol DraftsTableViewControllerDelegate {
|
||||
protocol DraftsTableViewControllerDelegate: class {
|
||||
func draftSelectionCanceled()
|
||||
func shouldSelectDraft(_ draft: DraftsManager.Draft, completion: @escaping (Bool) -> Void)
|
||||
func draftSelected(_ draft: DraftsManager.Draft)
|
||||
|
@ -17,7 +17,7 @@ protocol DraftsTableViewControllerDelegate {
|
|||
|
||||
class DraftsTableViewController: UITableViewController {
|
||||
|
||||
var delegate: DraftsTableViewControllerDelegate?
|
||||
weak var delegate: DraftsTableViewControllerDelegate?
|
||||
|
||||
init() {
|
||||
super.init(nibName: "DraftsTableViewController", bundle: nil)
|
||||
|
|
|
@ -10,7 +10,7 @@ import UIKit
|
|||
|
||||
class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
||||
|
||||
let mastodonController: MastodonController
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
|
|
|
@ -14,7 +14,7 @@ class NotificationsPageViewController: SegmentedPageViewController {
|
|||
private let notificationsTitle = NSLocalizedString("Notifications", comment: "notifications tab title")
|
||||
private let mentionsTitle = NSLocalizedString("Mentions", comment: "mentions tab title")
|
||||
|
||||
let mastodonController: MastodonController
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
self.mastodonController = mastodonController
|
||||
|
|
|
@ -10,7 +10,7 @@ import UIKit
|
|||
import Combine
|
||||
import Pachyderm
|
||||
|
||||
protocol InstanceSelectorTableViewControllerDelegate {
|
||||
protocol InstanceSelectorTableViewControllerDelegate: class {
|
||||
func didSelectInstance(url: URL)
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ fileprivate let instanceCell = "instanceCell"
|
|||
|
||||
class InstanceSelectorTableViewController: UITableViewController {
|
||||
|
||||
var delegate: InstanceSelectorTableViewControllerDelegate?
|
||||
weak var delegate: InstanceSelectorTableViewControllerDelegate?
|
||||
|
||||
var dataSource: DataSource!
|
||||
var searchController: UISearchController!
|
||||
|
@ -55,7 +55,7 @@ class InstanceSelectorTableViewController: UITableViewController {
|
|||
tableView.rowHeight = UITableView.automaticDimension
|
||||
tableView.estimatedRowHeight = 120
|
||||
|
||||
dataSource = DataSource(tableView: tableView, cellProvider: { (tableView, indexPath, item) -> UITableViewCell? in
|
||||
dataSource = DataSource(tableView: tableView, cellProvider: { [weak self] (tableView, indexPath, item) -> UITableViewCell? in
|
||||
switch item {
|
||||
case let .selected(instance):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: instanceCell, for: indexPath) as! InstanceTableViewCell
|
||||
|
|
|
@ -12,7 +12,7 @@ import SafariServices
|
|||
|
||||
class ProfileTableViewController: EnhancedTableViewController {
|
||||
|
||||
let mastodonController: MastodonController
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
var accountID: String! {
|
||||
didSet {
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
protocol InstanceTimelineViewControllerDelegate {
|
||||
protocol InstanceTimelineViewControllerDelegate: class {
|
||||
func didSaveInstance(url: URL)
|
||||
func didUnsaveInstance(url: URL)
|
||||
}
|
||||
|
||||
class InstanceTimelineViewController: TimelineTableViewController {
|
||||
|
||||
var delegate: InstanceTimelineViewControllerDelegate?
|
||||
weak var delegate: InstanceTimelineViewControllerDelegate?
|
||||
|
||||
let instanceURL: URL
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import Pachyderm
|
|||
class TimelineTableViewController: EnhancedTableViewController {
|
||||
|
||||
var timeline: Timeline!
|
||||
let mastodonController: MastodonController
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
var timelineSegments: [[(id: String, state: StatusState)]] = [] {
|
||||
didSet {
|
||||
|
|
|
@ -14,7 +14,7 @@ class TimelinesPageViewController: SegmentedPageViewController {
|
|||
private let federatedTitle = NSLocalizedString("Federated", comment: "federated timeline tab title")
|
||||
private let localTitle = NSLocalizedString("Local", comment: "local timeline tab title")
|
||||
|
||||
let mastodonController: MastodonController
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
self.mastodonController = mastodonController
|
||||
|
|
|
@ -10,7 +10,7 @@ import UIKit
|
|||
import SafariServices
|
||||
import Pachyderm
|
||||
|
||||
protocol TuskerNavigationDelegate {
|
||||
protocol TuskerNavigationDelegate: class {
|
||||
|
||||
var apiController: MastodonController { get }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import UIKit
|
|||
|
||||
class AccountTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: TuskerNavigationDelegate?
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
var mastodonController: MastodonController! { delegate?.apiController }
|
||||
|
||||
@IBOutlet weak var avatarImageView: UIImageView!
|
||||
|
|
|
@ -11,13 +11,13 @@ import Pachyderm
|
|||
import Gifu
|
||||
import AVFoundation
|
||||
|
||||
protocol AttachmentViewDelegate {
|
||||
protocol AttachmentViewDelegate: class {
|
||||
func showAttachmentsGallery(startingAt index: Int)
|
||||
}
|
||||
|
||||
class AttachmentView: UIImageView, GIFAnimatable {
|
||||
|
||||
var delegate: AttachmentViewDelegate?
|
||||
weak var delegate: AttachmentViewDelegate?
|
||||
|
||||
var playImageView: UIImageView!
|
||||
|
||||
|
@ -71,8 +71,8 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
|||
}
|
||||
|
||||
func loadImage() {
|
||||
ImageCache.attachments.get(attachment.url) { (data) in
|
||||
guard let data = data else { return }
|
||||
ImageCache.attachments.get(attachment.url) { [weak self] (data) in
|
||||
guard let self = self, let data = data else { return }
|
||||
DispatchQueue.main.async {
|
||||
if self.attachment.url.pathExtension == "gif" {
|
||||
self.animate(withGIFData: data)
|
||||
|
|
|
@ -11,7 +11,7 @@ import Pachyderm
|
|||
|
||||
class AttachmentsContainerView: UIView {
|
||||
|
||||
var delegate: AttachmentViewDelegate?
|
||||
weak var delegate: AttachmentViewDelegate?
|
||||
|
||||
var statusID: String!
|
||||
var attachments: [Attachment]!
|
||||
|
|
|
@ -10,14 +10,14 @@ import UIKit
|
|||
import Photos
|
||||
import AVFoundation
|
||||
|
||||
protocol ComposeMediaViewDelegate {
|
||||
protocol ComposeMediaViewDelegate: class {
|
||||
func didRemoveMedia(_ mediaView: ComposeMediaView)
|
||||
func descriptionTextViewDidChange(_ mediaView: ComposeMediaView)
|
||||
}
|
||||
|
||||
class ComposeMediaView: UIView {
|
||||
|
||||
var delegate: ComposeMediaViewDelegate?
|
||||
weak var delegate: ComposeMediaViewDelegate?
|
||||
|
||||
@IBOutlet weak var imageView: UIImageView!
|
||||
@IBOutlet weak var descriptionTextView: UITextView!
|
||||
|
|
|
@ -15,8 +15,7 @@ private let emojiRegex = try! NSRegularExpression(pattern: ":(\\w+):", options:
|
|||
|
||||
class ContentTextView: LinkTextView {
|
||||
|
||||
// todo: should be weak
|
||||
var navigationDelegate: TuskerNavigationDelegate?
|
||||
weak var navigationDelegate: TuskerNavigationDelegate?
|
||||
var mastodonController: MastodonController? { navigationDelegate?.apiController }
|
||||
|
||||
var defaultFont: UIFont = .systemFont(ofSize: 17)
|
||||
|
|
|
@ -11,7 +11,7 @@ import Pachyderm
|
|||
|
||||
class HashtagTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: TuskerNavigationDelegate?
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
|
||||
@IBOutlet weak var hashtagLabel: UILabel!
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import SwiftSoup
|
|||
|
||||
class ActionNotificationGroupTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: TuskerNavigationDelegate?
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
var mastodonController: MastodonController! { delegate?.apiController }
|
||||
|
||||
@IBOutlet weak var actionImageView: UIImageView!
|
||||
|
|
|
@ -11,7 +11,7 @@ import Pachyderm
|
|||
|
||||
class FollowNotificationGroupTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: TuskerNavigationDelegate?
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
var mastodonController: MastodonController! { delegate?.apiController }
|
||||
|
||||
@IBOutlet weak var avatarStackView: UIStackView!
|
||||
|
|
|
@ -11,7 +11,7 @@ import Pachyderm
|
|||
|
||||
class FollowRequestNotificationTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: TuskerNavigationDelegate?
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
var mastodonController: MastodonController! { delegate?.apiController }
|
||||
|
||||
@IBOutlet weak var stackView: UIStackView!
|
||||
|
|
|
@ -15,7 +15,7 @@ protocol ProfileHeaderTableViewCellDelegate: TuskerNavigationDelegate {
|
|||
|
||||
class ProfileHeaderTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: ProfileHeaderTableViewCellDelegate?
|
||||
weak var delegate: ProfileHeaderTableViewCellDelegate?
|
||||
var mastodonController: MastodonController! { delegate?.apiController }
|
||||
|
||||
@IBOutlet weak var headerImageView: UIImageView!
|
||||
|
|
|
@ -16,7 +16,7 @@ protocol StatusTableViewCellDelegate: TuskerNavigationDelegate {
|
|||
|
||||
class BaseStatusTableViewCell: UITableViewCell {
|
||||
|
||||
var delegate: StatusTableViewCellDelegate? {
|
||||
weak var delegate: StatusTableViewCellDelegate? {
|
||||
didSet {
|
||||
contentTextView.navigationDelegate = delegate
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue