0

我设置了一个NSRuleEditor供用户编辑规则以过滤数组,我没有麻烦用户编辑规则,但我找不到显示我为用户保存的规则的方法,有人有什么想法吗?

我为每一行准备了规则并从委托方法返回,当用户单击“+”按钮时,新规则按我的预期出现

#pragma mark - NSRuleEditorDelegate

- (NSInteger)ruleEditor:(NSRuleEditor *)editor numberOfChildrenForCriterion:(nullable id)criterion withRowType:(NSRuleEditorRowType)rowType {
    RuleCriterion *ruleCriterion = criterion;

    if (rowType == NSRuleEditorRowTypeCompound) {
        if (ruleCriterion == nil) {
            return self.compoundCriteria.count;
        } else {
            return ruleCriterion.numberOfChildren;
        }
    } else {
        if (ruleCriterion == nil) {
            return self.simpleCriteria.count;
        } else {
            return ruleCriterion.numberOfChildren;
        }
    }
}

- (id)ruleEditor:(NSRuleEditor *)editor child:(NSInteger)index forCriterion:(nullable id)criterion withRowType:(NSRuleEditorRowType)rowType {
    RuleCriterion *ruleCriterion = criterion;

    if (rowType == NSRuleEditorRowTypeCompound && ruleCriterion == nil) {
        return self.compoundCriteria[index];
    } else if (rowType == NSRuleEditorRowTypeSimple && ruleCriterion == nil) {
        return self.simpleCriteria[index];
    } else {
        return [ruleCriterion childAtIndex:index];
    }
}

- (id)ruleEditor:(NSRuleEditor *)editor displayValueForCriterion:(id)criterion inRow:(NSInteger)row {
    RuleCriterion *ruleCriterion = criterion;

    return ruleCriterion.displayValue;
}
4

1 回答 1

0

插入一行

- (void)insertRowAtIndex:(NSInteger)rowIndex withType:(NSRuleEditorRowType)rowType asSubrowOfRow:(NSInteger)parentRow animate:(BOOL)shouldAnimate;

设置条件并显示行的值

- (void)setCriteria:(NSArray *)criteria andDisplayValues:(NSArray *)values forRowAtIndex:(NSInteger)rowIndex;
于 2019-04-15T13:36:55.067 回答