在开发人员文档中,我发现了这一点:
有人可以举个例子吗?
最佳答案
===========编辑=============
正如我研究的那样,NSRuleEditor
类头包含有关绑定(bind)的下一个文档:
* -- Bindings support -- */
/* Sets the class used when creating a new row in the "rows" binding; this class should be KVC and KVO compliant for the key paths listed below. By default this is NSMutableDictionary */
- (void)setRowClass:(Class)rowClass;
- (Class)rowClass;
/* Set and get the key path for the row type, which is used to get the row type in the "rows" binding. The row type is a value property of type NSRuleEditorRowType. The default is @"rowType". */
- (void)setRowTypeKeyPath:(NSString *)keyPath;
- (NSString *)rowTypeKeyPath;
/* Set and get the key path for the subrows, which is used to determined nested rows in the "rows" binding. The subrows property is an ordered to-many relationship containing additional bound row objects. The default is @"subrows". */
- (void)setSubrowsKeyPath:(NSString *)keyPath;
- (NSString *)subrowsKeyPath;
/* Set and get the criteria key path, which determines the criteria for a row in the "rows" binding. (The criteria objects are what the delegate returns from - ruleEditor: child: forCriterion: withRowType:). The criteria property is an ordered to-many relationship. The default is @"criteria". */
- (void)setCriteriaKeyPath:(NSString *)keyPath;
- (NSString *)criteriaKeyPath;
/* Set and get the display values key path, which determines the display values for a row (the display values are what the delegate returns from - ruleEditor: displayValueForCriterion: inRow:). The criteria property is an ordered to-many relationship. The default is @"displayValues". */
- (void)setDisplayValuesKeyPath:(NSString *)keyPath;
- (NSString *)displayValuesKeyPath;
为了扩大答案,我给出了下一个示例,以便您了解如何将自己的类绑定(bind)为行:
@interface BindObject : NSObject
@property (nonatomic, assign) NSInteger rowType;
@property (nonatomic, strong) NSMutableArray *subrows;
@property (nonatomic, strong) NSMutableArray *displayValues;
@property (nonatomic, strong) NSMutableArray *criteria;
@end
// binding custom class as row class
[self.ruleEditor setRowClass:[BindObject class]];
现在,当您向
NSRuleEditor
添加新行时,将使用您的类。您还可以更改KeyPath,以便自定义行类中的字段(ivars/properties)的调用方式可能与文档中指定的方式不同。希望这可以帮助您了解NSRuleEditor的工作方式。
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
我找到了this article,它应该可以帮助您了解NSRuleEditor的工作方式。
关于objective-c - 将NSRuleEditor与数组绑定(bind),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9081976/