-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change a few delegate properties in Signup to be weak references #21064
Conversation
@@ -37,7 +37,7 @@ class SignupEpilogueCell: UITableViewCell { | |||
private let passwordTopMargin: CGFloat = 16 | |||
|
|||
private var cellType: EpilogueCellType? | |||
open var delegate: SignupEpilogueCellDelegate? | |||
open weak var delegate: SignupEpilogueCellDelegate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a retain cycle between the SignupEpilogueTableViewController
and this SignupEpilogueCell
.
WordPress-iOS/WordPress/Classes/ViewRelated/NUX/SignupEpilogueTableViewController.swift
Line 214 in 48b8a39
cell.delegate = self |
open var dataSource: SignupEpilogueTableViewControllerDataSource? | ||
open var delegate: SignupEpilogueTableViewControllerDelegate? | ||
open weak var dataSource: SignupEpilogueTableViewControllerDataSource? | ||
open weak var delegate: SignupEpilogueTableViewControllerDelegate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WordPress-iOS/WordPress/Classes/ViewRelated/NUX/SignupEpilogueViewController.swift
Lines 71 to 79 in 48b8a39
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
super.prepare(for: segue, sender: sender) | |
if let vc = segue.destination as? SignupEpilogueTableViewController { | |
vc.credentials = credentials | |
vc.socialService = socialService | |
vc.dataSource = self | |
vc.delegate = self | |
} | |
I'm not sure if a view controller would hold strong references to segue instances, which would cause a retain cycle in our case here. But considering how this delegate
and dataSource
are used, they should be weak references anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I jumped on this memory leak in other investigations.
@@ -12,7 +12,7 @@ class SignupUsernameViewController: UIViewController { | |||
|
|||
open var currentUsername: String? | |||
open var displayName: String? | |||
open var delegate: SignupUsernameViewControllerDelegate? | |||
open weak var delegate: SignupUsernameViewControllerDelegate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This delegate
is used in a similar way as #21064 (comment)
WordPress-iOS/WordPress/Classes/ViewRelated/NUX/SignupEpilogueViewController.swift
Lines 80 to 88 in 48b8a39
if let vc = segue.destination as? SignupUsernameViewController { | |
vc.currentUsername = updatedUsername ?? epilogueUserInfo?.username | |
vc.displayName = updatedDisplayName ?? epilogueUserInfo?.fullName | |
vc.delegate = self | |
// Empty Back Button | |
navigationItem.backBarButtonItem = UIBarButtonItem(title: String(), style: .plain, target: nil, action: nil) | |
} | |
} |
@@ -4,7 +4,7 @@ import WordPressAuthenticator | |||
class SignupUsernameTableViewController: UITableViewController, SearchTableViewCellDelegate { | |||
open var currentUsername: String? | |||
open var displayName: String? | |||
open var delegate: SignupUsernameViewControllerDelegate? | |||
open weak var delegate: SignupUsernameViewControllerDelegate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a retain cycle between SignupUsernameViewController
and SignupUsernameTableViewController
.
WordPress-iOS/WordPress/Classes/ViewRelated/NUX/SignupUsernameViewController.swift
Lines 31 to 36 in 48b8a39
if let vc = segue.destination as? SignupUsernameTableViewController { | |
usernamesTableViewController = vc | |
vc.delegate = self | |
vc.displayName = displayName | |
vc.currentUsername = currentUsername | |
} |
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
Relates to #21050.
This PR changed a few delegate properties' declaration. I'll post PR comments in detail regarding those individual changes.
Regression Notes
Potential unintended areas of impact
None.
What I did to test those areas of impact (or what existing automated tests I relied on)
None.
What automated tests I added (or what prevented me from doing so)
None.
PR submission checklist:
RELEASE-NOTES.txt
if necessary.UI Changes testing checklist: N/A