NSRangeException on UITableViewController with mixed static / dynamic content

Using iOS6 and storyboards, I have a UITableViewController with three sections.

The first 2 sections are static, and the third is dynamic.

I redefined numberOfRowsInSection, cellForRowAtIndexPathand heightForRowAtIndexPath, to correctly defer to super for sections 0 and 1 and return the corresponding values ​​from my data model for section 2.

However, I get an NSRangeException in main () when the number of lines in my data exceeds the number of lines configured in the Storyboard for the third section:

'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]' *** First throw call stack: (0x22f3012 0x178ae7e 0x22a8b44 0xb0ece4 0x8feee3 0x784f13 0x71940c 0x784a7b 0x789919 0x7899cf 0x7721bb 0x782b4b 0x71f2dd 0x179e6b0 0x558fc0 0x54d33c 0x54d150 0x4cb0bc 0x4cc227 0x4cc8e2 0x22bbafe 0x22bba3d 0x22997c2 0x2298f44 0x2298e1b 0x26867e3 0x2686668 0x6ceffc 0x2c4d 0x2b75) libc++abi.dylib: terminate called throwing an exception

What superclass methods need to be redefined to exclude this exception?

+5
source share
1 answer

, , :

-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath { return 0; }

, , , UITableViewController:

  • -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

  • -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

  • -(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

  • -(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath

, - .

+11

All Articles