NSController's class accessing NSDocument methods
NSController's class accessing NSDocument methods
- Subject: NSController's class accessing NSDocument methods
- From: BareFeet <email@hidden>
- Date: Tue, 8 Sep 2009 14:03:32 +1000
Hi all,
I have a fairly simple app, with an Entity table and a DataRows table
(each has a controller), set up using bindings (no Core Data). I've
set it up so when I select an Entity in the Entities table, the
DataRows table refreshes by calling my Entity.selection.dataRows
accessor method.
I have a MyDocument/File's Owner, NSOutlineView and bound
NSTreeController in a nib file. The outline/table shows a list of
Entities (nothing to do with Cocoa or CoreData) in the current
document/file. I have successfully set up accessor methods for
properties of Entity such as name and type. But I'm trying to set up
another accessor method (dataRows) that depends on the document path.
I can't see how to access the NSDocument methods from an Entity within
it. How is it done?
Here's some code:
// Entity.h
#import <Cocoa/Cocoa.h>
@interface Entity : NSObject
{
}
@property (retain) NSString* type;
@property (retain) NSString* name;
@property (retain) NSMutableArray* dataRows;
@end
// Entity.m
#import "Entity.h"
#import "MyGenerator.h"
@implementation Entity
@synthesize type;
@synthesize name;
@synthesize dataRows;
- (NSMutableArray*) dataRows
{
// *******
// I need this next line to instead get the path of the document that
// shares the controller's nib, rather than being hard coded.
// Something like: fileString = [[linkToDocument fileURL] path]
// *******
NSString* fileString = @"/Users/tom/Documents/MyFile.sqlitedb";
NSString* selectedEntityName = [self name];
NSMutableArray* dataRowsArray = [MyGenerator
dataRowsGivenFilePath:fileString entityName:selectedEntityName];
return dataRowsArray;
}
Thanks in advance,
Tom
BareFeet
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden