=========== EDIT =============
Như tôi đã nghiên cứu, tiêu đề lớp NSRuleEditor
chứa các tài liệu hướng dẫn tiếp theo về ràng buộc:
* -- 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;
Và để mở rộng câu trả lời, tôi đưa ra các ví dụ tiếp theo, do đó bạn sẽ hiểu làm thế nào để ràng buộc lớp của riêng bạn như hàng:
@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]];
Bây giờ khi bạn thêm hàng mới vào NSRuleEditor
lớp học của bạn sẽ được đã sử dụng. Bạn cũng có thể thay đổi KeyPath do đó các trường (ivars/properties) trong lớp hàng tùy chỉnh của bạn có thể được gọi khác với nó được speicifed trong tài liệu.
Hy vọng điều này sẽ giúp bạn hiểu cách NSRuleEditor hoạt động.
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
tôi đã tìm thấy this article, nó sẽ giúp bạn hiểu cách NSRuleEditor hoạt động.
Nguồn
2013-04-17 12:32:44
Đáng tiếc là mã bài viết và ví dụ không bao gồm cách liên kết "hàng" với NSRuleEditor. –
@GrahamMiln Tôi đã chỉnh sửa câu trả lời của mình để có thể hữu ích ngay bây giờ –