Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2010, 12:39 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 1
schaefera@me is on a distinguished road
Default Section Index leads to UI Table View Array index out of bounds

I created a Controller managing a UITableView. In order to support Section Indexes (right hand vertical bar of A to Z shortcuts) I enabled sections in the UITableView. In addition I want to be able to use the Edit Button (Top Right) to create a temporary 'Add Record' row. As long as there is only one section an empty table does not cause any problems. As soon as the sections are enabled the application will thrown an exception that an NSArray is empty during the insert of the temporary row (actually during the endUpdates call).

I made sure that my numberOfSections returns 1 and that my numberOfRowsInSection returns one more than what I have in my Core Data DB. Because there is a lot of code involved I am not posting it yet here but this is the exception I get in the console:

2010-09-10 21:55:53.611 iInventory[9085:207] BTC.numberOfRowsInSection(), section: 0, return this row count: 0, editing: 0
2010-09-10 21:55:53.611 iInventory[9085:207] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UITableView.m:920
2010-09-10 21:55:53.613 iInventory[9085:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (0) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).'
*** Call stack at first throw:
(
0 CoreFoundation 0x02672b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x027c240e objc_exception_throw + 47
2 CoreFoundation 0x0262b238 +[NSException raise:format:arguments:] + 136
3 Foundation 0x000cbe37 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:descr iption:] + 116
4 UIKit 0x0034bd37 -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 8719
5 UIKit 0x0033b54f -[UITableView insertRowsAtIndexPaths:withRowAnimation:] + 56
6 iInventory 0x0000852e -[BaseTableInsideAViewController setEditing:animated:] + 416
7 UIKit 0x003775b6 -[UIViewController(UINavigationControllerItem) _toggleEditing:] + 77
8 UIKit 0x002d17f8 -[UIApplication sendAction:to:from:forEvent:] + 119

For now I am looking for pointers on how to go ahead. This is especially strange because I only change the sectionNameKeyPath when I create the FetchResultController:


NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:[self managedObjectContext]
// sectionNameKeyPath:@"name"
// No section support for now
sectionNameKeyPath:sectionIndexColumnName
cacheName:detailEntityName
];

If I set this one to 'nil' then it works like a charm.

Thanks - Andy
schaefera@me is offline   Reply With Quote
Reply

Bookmarks

Tags
index out of bounds, section, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 341
13 members and 328 guests
bignoggins, carlandrews, cgokey, flamingliquid, givensur, hzwegjxg, ilmman, jenniead38, linkmx, mraalex, PixelInteractive, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0