How do I remove an object from an NSPageController object organized by Objects?

How can I add / remove objects in the page manager dynamically? All of the examples there set the organized objects property during the awakeFromNib method once during the lifetime of the application.

In my application, I have an NSMutableArray of NSObjects that I display in the main window using the NSPageController. For each NSObject, I create a corresponding ViewController in the delegate method - (NSViewController *) pageController:(NSPageController *) pageController viewControllerForIdentifier:(NSString *) identifier

.

During program execution, objects will be added / removed asynchronously to / from the mutable array. On each event, I set the ordered objects for the page control to a mutable array to accommodate changes — showing new objects and stopping showing deleted ones.

When objects are added everything works fine. But when objects are deleted, associated view / view controllers are retained in memory.

How can I "reset" the page control so that it will forget all about the deleted objects?

It looks like the page controller stores links (snapshots) of the remote object view dispatchers. And when other objects are added, their views are messed up.

+3


source to share


1 answer


Try using NSPageController in history mode as described here.

How do you implement NSPageController to navigate your web browsing history

and here

https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSPageController_Class/

In this case, you DO NOT need to implement

pageController:identifierForObject: 

      

and



pageController:viewControllerForIdentifier

      

and no need to install

arrangedObjects

      

But you need to call

navigateForwardToObject

      

every time you want to open a new page, this method allows the NSPageController to clear history and open a new page. Also do something like adding a new view to your pageController.view with a new page in this method. Also I made a view change in

didTransitionToObject

      

0


source







All Articles