UA-17470720-3

Jump to content


Photo
- - - - -

stuck using tableModel that i must be using wrong as i get a memory build up


  • Please log in to reply
3 replies to this topic

#1 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 25 February 2014 - 07:45 PM

so i have a simple view that is a SCViewController and on it, is a tableivew thats hooked up the to outlets as the tableView, and a segment control that when pressed reloads the table to display a different predicate

simple enough:)

 

but when i press the segment control, the tableview reloads and does what i want, but i see that in instruments (not leaking) but building up and not releasing objects each time the segment is pressed

 

so simple code is just, when the segment is pressed

    NSPredicate *predicate = nil;
    if (self.segmentControl.selectedSegmentIndex == 0) {
        predicate = [NSPredicate predicateWithFormat:@"complete == %@", @NO];
    }
    else if (self.segmentControl.selectedSegmentIndex == 1) {
        predicate = [NSPredicate predicateWithFormat:@"complete == %@", @YES];
    }
    else if (self.segmentControl.selectedSegmentIndex == 2) {
        predicate = [NSPredicate predicateWithFormat:@"dueDate < %@ && complete == %@",[NSDate date], @NO];
    }
    
    SCArrayOfObjectsModel *taskModel = [SCArrayOfObjectsModel modelWithTableView:self.tableView entityDefinition:self.taskDef filterPredicate:predicate];

    self.tableViewModel = taskModel;
    
    [self.tableViewModel reloadBoundValues];
    [self.tableViewModel.tableView reloadData];

so like i said it works in that the table reloads and displays exactly the objects its meant to, but in instruments i have 100's of objects that stay put and on each loop of the segment more and more are loading

 

so there must be a proper way to set the tableViewModel and that i am doing something wrong here?

 

Oz

 


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#2 Everett

Everett

    Ev

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 191 posts
  • LocationMichigan
Reputation: 60
Outstanding

Posted 26 February 2014 - 09:19 AM

Hi Oz,

 

just taking a quick guess here, but have you tried updating just the predicate on the SCArrayOfObjectsModel directly and then reloading rather then recreating the model? 

 

Something like this:

 

taskModel.dataFetchOptions.filterPredicate = newPredicate;

 

[self.tableViewModel.modeledTableView reloadData];

 

well, hope that helps.

Ev



#3 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 26 February 2014 - 04:05 PM

hey Everett

 

yup tried that too.. still the same thing

 

baffled:)


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#4 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 27 February 2014 - 07:20 PM

FYI.. it was a bug in STV that Tarek made a little fix for


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users