Welcome, Guest
Username Password: Remember me

reloadBoundValues doesn't know about predicate
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: reloadBoundValues doesn't know about predicate

reloadBoundValues doesn't know about predicate 1 year, 2 months ago #1

Hi, I have a table with custom detail view where I update a record by means other than stv. When I'm done I call:

[tableModel reloadBoundValues];
[tableModel.modeledTableView reloadData];


The problem is that the original predicate of the section is not respected. This is how my section looks like:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"category = %@", category];
 
SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withEntityClassDefinition:entryDef usingPredicate:predicate];
objectsSection.allowEditDetailView = NO;
 
[tableModel addSection:objectsSection];


Looking at the source code, I've found this method that gets called:

// override superclass method
- (void)reloadBoundValues
{
#ifdef _COREDATADEFINES_H
SCClassDefinition *classDef = [self firstClassDefinition];
if(classDef.entity)
self.items = [SCHelper generateObjectsArrayForEntityClassDefinition:classDef usingPredicate:itemsPredicate];
#endif
}


The problem is that predicate is (null) when it gets called, even though there is a predicate when I create the section. Am I doing something wrong, or is this a bug? I'm using version 2.0 RC2

Re: reloadBoundValues doesn't know about predicate 1 year, 2 months ago #2

Hi Oscar,

This actually does seem to be a bug, thanks a lot for reporting it! We'll get this fixed for our final STV 2.0 release (due before the end of this week). Thanks again!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: reloadBoundValues doesn't know about predicate 5 months ago #3

It looks like there's a regression involving this same code in 2.1.7. I have the same symptoms in that the SCArrayOfObjectsModel only uses the predicate once at creation time and then forgets it. This is using:
-initWithTableView:withViewController:withEntityClassDefinition:usingPredicate:(NSPredicate *)predicate

Digging into the source, I found the following, which shows why it immediately forgets the predicate.
- (id)initWithTableView:(UITableView *)_modeledTableView withViewController:(UIViewController *)_viewController withEntityClassDefinition:(SCClassDefinition *)classDefinition usingPredicate:(NSPredicate *)predicate
{
if(predicate)
self.itemsPredicate = predicate;
 
// Create the sectionItems array
NSMutableArray *sectionItems = [SCHelper generateObjectsArrayForEntityClassDefinition:classDefinition usingPredicate:self.itemsPredicate ascending:YES];
 
self = [self initWithTableView:_modeledTableView withViewController:_viewController withItems:sectionItems withClassDefinition:classDefinition];
[self callCoreDataObjectsLoadedDelegate];
 
return self;
}

The workaround is to set the itemsPredicate property after initialization.

Thanks for a great tool. I really appreciate the major time savings in my current project. Hopefully, the next version will be even better.

Warren
  • dodgio
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 1
The following user(s) said Thank You: tarekskr

Re: reloadBoundValues doesn't know about predicate 5 months ago #4

Hi Warren and welcome to our forums!

Thank you very much for reporting this! This glitch has actually been reported earlier and has already been fixed in our upcoming STV 2.2 version (release expected in the next few days). Thanks again.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
Time to create page: 1.73 seconds