Note that there are some explanatory texts on larger screens.

plurals
  1. POuitableview array contents being lost
    primarykey
    data
    text
    <p>I have an array which has 200 objects in it on page load i copy these (mutable copy) to a temp array called filteredarray which i then display in a uitableview. This all works fine :)</p> <p>i then have a segment selector which when selected is supposed to filter my orginal array using a predictate and filteredarray will now hole the contents of the objects which meet the predictate criteria again from what i can see this is working fine :)</p> <p>i then try and reload my table view ( again with filteredarray ) which when i step through seems to work ok for the first couple objects in filteredarray but then filteredarray seems to be "emptied" if thats the right word, and my code crashes just after the table has started to be refreshed. Im sure it must be a memory issue or something. im pretty new to objective c so any help would be much appreciated. i have listed some of my code below</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; filteredArray = [appDelegate.originalArray mutableCopy]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellidentifier = @"customcell"; customcell *cell = (customcell *)[tableView dequeueReusableCellWithIdentifier: cellidentifier]; array_details *arrayObj = [filteredArray objectAtIndex:indexPath.row]; // UITableViewCell cell needs creating for this UITableView row. if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"customcell" owner:self options:nil]; for (id currentObject in topLevelObjects) { if ([currentObject isKindOfClass:[customcell class]]) { cell = (customcell *) currentObject; break; } } } cell.line1.text = arrayObj.line1; cell.line2.text = arrayObj.line2; return cell; } -(IBAction)change_segment:(id)sender;{ if(segmentcontrol.selectedSegmentIndex == 2){ filteredArray = [appDelegate.originalArray mutableCopy]; NSPredicate *testForTrue = [NSPredicate predicateWithFormat:@"selected == YES"]; filteredArray = [filteredArray filteredArrayUsingPredicate:testForTrue]; } [my_table reloadData]; // its when i do this that the array filtered array seems to somehow get "emptied" </code></pre> <p>and my filteredarray is declared in my.h file as a nsmutable array </p> <pre><code>NSMutableArray *filteredArray; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload