Domanda

I have an NSWindowViewController that owns a nib file. One of the objects in the nib file is an NSTableView, managed by an NSTableViewController (also part of nib).

I want to implement the NSCoding protocol to save off all model data, some of which is contained within the NSTableViewController (which I'll refer to as TVC for short). Archiving the entire TVC seems like the wrong answer, since when its unarchived later, it won't be wired up to the nib. And while I could probably rewire everything programmatically...that just seems very kludgy.

I could have the NSWindowViewController grab the table data out of the TVC, but that would mean I would have to expose all of the ivars, which also seems like the wrong solution.

Whats the best way of archiving/unarchiving the data stored within the TVC?

È stato utile?

Soluzione

The table view controller should have a reference to the model that stores you data, or if your app is simple you might have that model data stored in an array or dictionary in the table view controller. It is that array or dictionary, whatever holds your data that should be archived, not the table view controller.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top