• 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: Calculating row heights for view-based table rows, on re-use throws error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calculating row heights for view-based table rows, on re-use throws error


  • Subject: Re: Calculating row heights for view-based table rows, on re-use throws error
  • From: Fritz Anderson <email@hidden>
  • Date: Sat, 18 Aug 2012 10:24:15 -0500

On 17 Aug 2012, at 9:15 PM, Erik Stainsby <email@hidden> wrote:

> I have a view-based table in which there are four distinct row types, representing distinct object types which may appear. The tableRowViews are in the nib and represented in the code here as xxxCellView entities.
>
>
> - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
>
> 	id obj = [_content objectAtIndex:row];

Notice that here you call objectAtIndex:, I assume from within your class RSTableController.

> 2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] *** -[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]

Notice that the system finds you have passed an illegal index to objectAtIndex:...

> 	2   CoreFoundation                      0x00007fff900455dc -[__NSArrayM objectAtIndex:] + 252
> 	3   RSSuperContactsX                    0x00000001000030f5 -[RSTableController tableView:heightOfRow:] + 101

... from within your -[RSTableController tableView:heightOfRow:].

> My expectation is that I ought to be able to clear the table (iterating through the rows and applying -removeRowsAtIndexes:withAnimation:  to discard the present rowViews, and start clean with the next record to be displayed, generating new rowViews as needed (because the number of component elements (phone numbers/email addresses/etc) will vary from one record to the next).

Not a good expectation, if you are altering a collection while you are iterating it. (You imply that's what you're doing, but it's not clear.) Doing so leaves the collection in an inconsistent condition, and anything that depends on the collection will have invalid data. (But see next paragraph.) The table view might, for instance, try to index to a row for which the backing data no longer exists.

UNLESS: You bracket your alterations to the table with -beginUpdates and -endUpdates.

> I have no iterator code running at the time this error occurs, so I suspect I have failed to correctly setup some aspect of the tableView/rowView mechanics.  Does anything suggest itself to anyone ?

The table view itself is iterating your rows.


By the way, heed the documentation for -beginUpdates :

> Note that these methods should be called to reflect changes in your model; they do not make any underlying model changes.



	— F


_______________________________________________

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: Calculating row heights for view-based table rows, on re-use throws error
      • From: Erik Stainsby <email@hidden>
References: 
 >Calculating row heights for view-based table rows, on re-use throws error (From: Erik Stainsby <email@hidden>)

  • Prev by Date: Re: Apple Aperture-like look & feel
  • Next by Date: Re: stripped down webview
  • Previous by thread: Calculating row heights for view-based table rows, on re-use throws error
  • Next by thread: Re: Calculating row heights for view-based table rows, on re-use throws error
  • Index(es):
    • Date
    • Thread