xmartlabs / XLForm

XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C.
MIT License
5.78k stars 953 forks source link

Predicates not functional #997

Open klattimer opened 6 years ago

klattimer commented 6 years ago

Sometimes I get a crash, sometimes it just doesn't do what it's meant to....

sample from my code.

NSString *const kXX = @"xx";

XLFormRowDescriptor *x = [XLFormRowDescriptor formRowDescriptorWithTag:kXX rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Test Predicate"];
x.value = @0;
[section addFormRow:x];

section = [XLFormSectionDescriptor formSection];
section.hidden = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"$%@ == 0", kXX]];
[form addFormSection:section];
klattimer commented 6 years ago

998

klattimer commented 6 years ago

It seems that the dictionary supplied for hidden and disabled predicates isn't in the appropriate format, I've added an iteration to fix it (not ideal), a cache of the correct data would be a better option.

This fixes it, but not entirely, there also seems to be an issue with predicates not being evaluated in rows inside of sections which are governed by predicates. I'll fix that issue in a separate PR.

klattimer commented 6 years ago

The rows in sections thing wasn't a real issue.