Hi folks,
I'm looking for advice on usage of arrays in tableviews.

I have a subclassed NSWindowController. In this class I have a method that extracts data from my core data model and formulates an array of dictionaries. Also in this class I have the tableview datasource methods. The datasource methods use the standard KVC column identifier thingies to populate the table. I'm having memory leaks and I'm sure its because of the way I'm making the array available to teh data source methods.

My interface file looks like this;

@interface MLimportController : NSWindowController {
        IBOutlet NSTableView    *transactionTable;
        IBOutlet NSArrayController *accountsController;
        
        NSMutableArray  *importedTransactions;
        NSManagedObject *selectedAccount;
        NSNumber *selectedTransferIndex;
}

- (IBAction) recordTransactions:(id)sender;
- (IBAction) deleteSelectedTransactions:(id)sender;
- (void) setAccountSortDescriptors: (NSArray *) descriptors;
- (NSArray *) accountSortDescriptors;
- (void) importFile:(NSString *)aFile;

//delegates
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)tableColumn row:(int)row; - (void)tableView:(NSTableView *)tableView setObjectValue:(id)newValue forTableColumn:(NSTableColumn *)tableColumn row:(int)row;
@end

In the importFile: method is where I build they array importedTransactions. However, as it will autorelease I [retain] it so its still hanging around for the tableView methods to access it. Is this the correct way of doing this? Or should I be declaring the NSArray as a @property and using getters/setters to use it?

My memory leak is resulting in importedTransactions always having a retainCount of 1, meaning the importController class can never be deallocated by my NSDocument, meaning the documentController can never close the document properly. I'm sure I'm doing this an ugly way.

(Leopard 10.5.5 with GC on)
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to