Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]?

 Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:], /SourceCache/UIKit/UIKit-2380.17/UITableViewRowData.m:400

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',     reason:'Failed to allocate data stores for 997008923 rows in section 0. Consider using fewer rows'

my code

 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {

   return 1;

  }


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

{

   return [appDelegate.purchaseArray count];

}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:  (NSIndexPath *)indexPath
   {
    static NSString *CellIdentifier = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault         reuseIdentifier:CellIdentifier];
    }
    return cell;
}    

-(void)viewWillAppear:(BOOL)animated
{

    [cartTbl reloadData];

}

i didn't get what's problem in this?

like image 576
user2071201 Avatar asked Mar 20 '13 11:03

user2071201


3 Answers

Check your tableView:heightForRowAtIndexPath:. Maybe you're returning something like NaN/+inf/-inf instead of height. That was my bug.

Remember this is not a crash for double and float types to divide by zero:

double d = 5.0;
double r = d/0.0;

So this can help you:

if (isnan(r) || isinf(r)) {
    // ...
}
like image 156
k06a Avatar answered Oct 19 '22 20:10

k06a


I also had failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]. In my case it was caused by set too small estimatedRowHeight while using:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
}

for autosizing tableView's cells. Setting estimatedRowHeight to 2.0 instead 1.0 solved problem.

like image 25
rafalkitta Avatar answered Oct 19 '22 21:10

rafalkitta


I had an error like this for a different reason. My app was working fine, when I decided to change something in my view model (The object that I was binding my table to). I deleted a property, and recompiled. Suddenly the app was throwing this error.

It turned out that there was still a reference to the deleted property in the code that the compiler didn't catch. I had cleaned and rebuilt several times, and the compiler never caught that error that I missed.

Restarting xcode made the build fail, with the offending line now highlighted as an error. Once I fixed that, everything was fine again.

If you encounter bad access errors like this, and see weird stuff in the debugger, like properties with values that should be assigned to other properties, then you might have an error that should have kept your build from compiling that xcode just didn't catch somehow. A restart might fix it - it's worth a try.

like image 21
NetHawk Avatar answered Oct 19 '22 20:10

NetHawk