Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Controller/View life cycle fix. #85

Merged
merged 6 commits into from
Jul 5, 2013
Merged

Controller/View life cycle fix. #85

merged 6 commits into from
Jul 5, 2013

Conversation

anozaki
Copy link
Contributor

@anozaki anozaki commented May 13, 2013

This fixes issue #75, but fixes controller/view life cycle in general.

I was going to attach this request to issue #75 but could not figure it out.

@ghost ghost assigned jspahrsummers May 13, 2013
@anozaki
Copy link
Contributor Author

anozaki commented May 13, 2013

What we really want is a weak reference to the view controller in the view... but I don't think this is possible with associative property. But in addition to that...

From "Transitioning to ARC Release Notes":

Note: In addition, in OS X v10.7, you cannot create weak references to instances of NSFontManager, NSFontPanel, NSImage, NSTableCellView, NSViewController, NSWindow, and NSWindowController. In addition, in OS X v10.7 no classes in the AV Foundation framework support weak references

@@ -30,6 +39,11 @@ -(void)setView:(NSView *)view
{
super.view = view;
self.view.rbl_viewController = self;

if (_currentView.rbl_viewController == self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part. Why not just check self.view before invoking super?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling self.view before super.view = view would cause an infinit loop.

self.view accessor instantiates loadView or the nib and ends up calling setView.

@jspahrsummers
Copy link
Contributor

🚝

@anozaki
Copy link
Contributor Author

anozaki commented May 13, 2013

I only updated the dealloc's curly brace. The reset of the file actually has it on the next line.

@@ -30,6 +38,11 @@ -(void)setView:(NSView *)view
{
super.view = view;
self.view.rbl_viewController = self;

if (_currentView.rbl_viewController == self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling self.view before super.view = view would cause an infinit loop.

self.view accessor instantiates loadView or the nib and ends up calling setView.

Hmm, very true, but this seems hacky. I don't think I have a better solution right now, though.

@jspahrsummers
Copy link
Contributor

Thanks for fixing those up! Just a couple more notes.

@alanjrogers
Copy link
Contributor

@anozaki was this ready for re-review? We usually leave a top level comment when we're done with a round of changes.

@anozaki
Copy link
Contributor Author

anozaki commented Jun 28, 2013

Yeah, should be ready.

@tonyarnold
Copy link

I'm seeing the effects of this bug, and would love to see this fix merged (even if it's not ideal).

@joshaber
Copy link
Contributor

joshaber commented Jul 5, 2013

@jspahrsummers This looks good to me. Any hangups?

@jspahrsummers
Copy link
Contributor

This fell off my radar somehow. Sorry about that!

Looks 💎. Thanks!

jspahrsummers added a commit that referenced this pull request Jul 5, 2013
Controller/View life cycle fix.
@jspahrsummers jspahrsummers merged commit 119a05a into github:master Jul 5, 2013
@jspahrsummers jspahrsummers removed their assignment May 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants