Re: NSTableView retain count problem
Re: NSTableView retain count problem
- Subject: Re: NSTableView retain count problem
- From: Mark Munz <email@hidden>
- Date: Sat, 21 Nov 2009 21:55:54 -0800
Since records is a instance variable, you don't want to autorelease
it. You want it to stick around until the object is destroyed.
Delete the [records autorelease]; reference in createDictionary.
then add
(void) dealloc
{
[records release];
[super dealloc];
}
On Sat, Nov 21, 2009 at 3:49 PM, Shane
<email@hidden> wrote:
> I have an NSTableView where the data source and delegate are assigned
> to an NSViewController, and in this controller I have the two data
> source methods.
>
> numberOfRowsInTableView
> tableView: objectValueForTableColumn row:
>
> This project was previously done through xcode using Tiger, and I've
> just now imported it in Snow Leopard. My problem is that my table view
> isn't being populated. I see numberOfRowsInTableView being called, but
> it's always returning 0. So I looked at 'records' and the retain count
> is always 0, yet 'records' in my other method 'createDictionary' which
> populates the table is always 1.
>
> @interface DataViewController : MainViewController {
> …
> NSMutableArray *records;
> }
>
> - (id) init
> {
> records = [[NSMutableArray alloc] init];
> }
>
> - (int) createDictionary
> {
> [records autorelease];
>
> // retain count for records at this point is 1.
>
> while (…) {
> [records addObject:currentLine];
> }
>
> [myTableView reloadData];
>
> // retain count for records at this point is 1.
> // records is not populated and returns the proper count.
>
> return [records count];
> }
>
>
> This method gets called before (when NSTableView is setup) and during
> createDictionary (where I populate my NSTableView) and always returns
> 0.
>
> - (int) numberOfRowsInTableView:(NSTableView *)tableView
> {
> // retain count for records at this point is always 0.
> return [records count];
> }
>
>
> Anyone see what I'm doing wrong here, or know how I can better track this down?
> _______________________________________________
>
> 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
>
--
Mark Munz
unmarked software
http://www.unmarked.com/
_______________________________________________
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