CPViewController view will... notifications

37 views
Skip to first unread message

Arjen Schipmolder

unread,
Sep 15, 2016, 8:01:03 PM9/15/16
to objec...@googlegroups.com

Hi all,

 

I believe this subject has been discussed quite some time ago but I couldn’t find it anymore so wanted to ask you once more, but does anyone know a good way to get notifications when CPViewcontroller’s views get changed, e.g. when they get created or destroyed etc?

 

I’m using quite a few CPNotifications and one of the problems I’m running into is that removed subviews that listen to a certain notification still respond after they have been removed yet not garbage collected yet.

Ideally I’d like to remove them as observer when the view is removed from within the CPViewController but have so far not found a way to do so.

 

Thanks

Arjen

 

Cacaodev cacaodev

unread,
Sep 17, 2016, 4:36:39 AM9/17/16
to Cappuccino & Objective-J
Hi Arjen,

CPViewController's methods -viewWill|DidAppear and -viewWill|DidDisappear are available and subclassable. I believe this is what you are looking for.   

Arjen Schipmolder

unread,
Sep 17, 2016, 5:11:49 PM9/17/16
to objec...@googlegroups.com

Hmm, I thought I’d tried those but can’t find them in the src or documentation.

Are you sure those work for you?

 

https://github.com/cappuccino/cappuccino/blob/v0.9.9/AppKit/CPViewController.j

http://www.cappuccino-project.org/learn/documentation/interface_c_p_view_controller.html

 

I’m running a slightly dated version of cappuccino but don’t really have time to update and test everything unless I’ll have to so please let me know.

 

Arjen

 

--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

Cacaodev cacaodev

unread,
Sep 17, 2016, 5:45:25 PM9/17/16
to Cappuccino & Objective-J
I should have mentioned it have been pushed a few weeks ago so in the master branch only.

Arjen Schipmolder

unread,
Sep 17, 2016, 5:46:12 PM9/17/16
to objec...@googlegroups.com

Ah great, I’ll check that out straight away.

 

Thanks!

Arjen Schipmolder

unread,
Oct 27, 2016, 2:54:25 AM10/27/16
to objec...@googlegroups.com

Ok, I have finally found some time to update my entire project to the latest master and so far so good, thanks a lot for that!

However, I do have a quick question, but am I correct to say that the -viewWill|DidAppear and -viewWill|DidDisappear methods are only called in the viewcontroller itself and not in it’s super classes? If it’s not then there must be something in my code but I wanted to ask first anyway…

 

The behaviour I’m seeing now is that if a subclassed PSViewController (itself a subclass of CPViewController) does contain a viewDidDisappear method it’s called as expected, however if it doesn’t contain the method at all it does not call the viewDidDisappear method in the super PSViewController either. I suspect it’s got something to do with the inner workings of CPNotificationCenter but I’m not sure at all.

 

Thanks

Cacaodev cacaodev

unread,
Oct 27, 2016, 2:59:29 PM10/27/16
to Cappuccino & Objective-J
Yes, this is what happens. The view controller registers for notifications only if it implements (whatever the inheritance) the view*Appear methods.
Reply all
Reply to author
Forward
0 new messages