• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableView retain count problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSTableView retain count problem
      • From: Shane <email@hidden>
References: 
 >NSTableView retain count problem (From: Shane <email@hidden>)

  • Prev by Date: Re: NSTableView retain count problem
  • Next by Date: Re: NSTableView retain count problem
  • Previous by thread: Re: NSTableView retain count problem
  • Next by thread: Re: NSTableView retain count problem
  • Index(es):
    • Date
    • Thread