searchDisplayController 引起的数组越界处理办法
下面把searchDisplayController引起的数组越界处理办法给大家分享如下:
当[searchDisplayController.searchResultsTableViewsetSeparatorStyle:UITableViewCellSeparatorStyleNone]时,发送了崩溃
错误提示如下:
Terminatingappduetouncaughtexception'NSRangeException',reason:'***-[__NSArrayIobjectAtIndex:]:index1beyondbounds[0..0]' ***Firstthrowcallstack: ( 0CoreFoundation0x000000010c6c6c65__exceptionPreprocess+165 1libobjc.A.dylib0x000000010c35fbb7objc_exception_throw+45 2CoreFoundation0x000000010c5bd17e-[__NSArrayIobjectAtIndex:]+190 3UIKit0x000000010d230fd2-[UITableViewDataSourcetableView:indentationLevelForRowAtIndexPath:]+106 4UIKit0x000000010cdfb1b9__53-[UITableView_configureCellForDisplay:forIndexPath:]_block_invoke+1711
查了好久才查到原因:在错误log中有提示
3UIKit0x000000010d230fd2-[UITableViewDataSourcetableView:indentationLevelForRowAtIndexPath:]+106 解决方法: -(NSInteger)tableView:(UITableView*)tableViewindentationLevelForRowAtIndexPath:(NSIndexPath*)indexPath { return0; }
以上代码就是针对searchDisplayController引起的数组越界处理办法的解决方案,希望对大家有所帮助。