> @interface DataViewController : MainViewController {
> …
> NSMutableArray *records;
> }
>
> - (id) init
> {
> records = [[NSMutableArray alloc] init];
> }
>
> - (int) createDictionary
> {
> [records autorelease];
I'm assuming you're not using GC since you're looking at retain counts. So, why
autorelease records here? Your records variable is going to be fine for the
duration of this method, but as soon as your application goes through its main
run loop and pops the autorelease pool, your records variable will have been
released. Maybe that's what you're seeing with the retain count.
> // 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];
> }
By the time this method gets called, chances are that you've been through the
run loop and your records variable is gone. If your application doesn't crash,
that's pure luck. Try NSZombieEnabled and set a bunch of breakpoints (Google
NSZombieEnabled to see here) to see what's going on.
Hope this helps,
Hank
_______________________________________________
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]