首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用数组绑定行NSRuleEditor

用数组绑定行NSRuleEditor
EN

Stack Overflow用户
提问于 2012-01-31 15:16:45
回答 1查看 565关注 0票数 8

在开发人员文档中,我发现了以下内容:

NSRuleEditor公开了一个绑定,rows。可以将rows绑定到有序集合(例如NSMutableArray的实例)。集合中的每个对象都应该具有以下属性:

  • @"rowType“表示行的类型(NSRuleEditorRowType)的整数。
  • @“子行”是一个有序的多个关系(例如NSMutableArray的一个实例),包含给定行的直接嵌套子行。
  • @"displayValues“是一个有序到多个的关系,包含行的显示值。
  • @“条件”一种排序为-多个包含行标准的关系。

任何人都可以举例说明如何做到这一点?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-17 12:32:44

===========编辑=============

正如我所研究的,NSRuleEditor类头包含关于绑定的下一个文档:

代码语言:javascript
复制
* -- 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;

为了扩展答案,我将给出下一个示例,以便您了解如何将自己的类绑定为行:

代码语言:javascript
复制
@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/属性)的调用可能与文档中指定的字段不同。

希望这将有助于您理解NSRuleEditor的工作原理。

-=-

我已经找到了这篇文章,它将帮助您理解NSRuleEditor是如何工作的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9081976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档