NSOutlineView loading of data
NSOutlineView loading of data
- Subject: NSOutlineView loading of data
- From: Brandon Meyer <email@hidden>
- Date: Mon, 3 Oct 2005 17:56:13 -0500
I have an NSOutlineView that I am trying to load data into. I can
create 'nodes', edit the name, and then save the contents of the
OutlineView into a file. However, I cannot seem to properly load the
data back into the OutlineView.
One thing that I've noticed, if I create a new 'node' and click
on it, it loads the data into the TableView that is associated with
the first 'node' I created and then saved.
The OutlineView has its delegate and dataSource set to the
appropriate controller.
Here are my loading/saving methods:
//
========================================================================
=====
// Saving of data
//----------------------------------------------------------------------
-------
- (void) saveDataToDisk
{
NSString * path = [self pathForDataFile];
NSMutableDictionary * rootObject;
rootObject = [NSMutableDictionary dictionary];
[rootObject setValue: [self categories] forKey:@"categories"];
[NSKeyedArchiver archiveRootObject: rootObject toFile: path];
}
//
========================================================================
=====
// Loading of data
//----------------------------------------------------------------------
-------
- (void) loadDataFromDisk
{
NSString * path = [self pathForDataFile];
NSDictionary * rootObject;
rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
[self setCategories: [rootObject valueForKey:@"categories"]];
}
- (NSMutableArray *) categories
{
return _categories;
}
- (void) setCategories: (NSArray *)newCategories
{
if (_categories != newCategories)
{
[_categories autorelease];
_categories = [[NSMutableArray alloc] initWithArray:
newCategories];
}
}
Thanks in advance for any advice!
Brandon
P.S. I can provide any other required information needed. Just ask!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden