2012-01-31 22 views
8

Trong tài liệu hướng dẫn phát triển tôi tìm thấy này:hàng Bind NSRuleEditor với mảng

NSRuleEditor lộ một ràng buộc, rows. Bạn có thể liên kết rows với một bộ sưu tập được yêu cầu (chẳng hạn như phiên bản NSMutableArray). Mỗi đối tượng trong bộ sưu tập nên có các thuộc tính sau:

  • @ "ROWTYPE" Một số nguyên đại diện cho các loại hàng (NSRuleEditorRowType).

  • @ "subrows" Một mối quan hệ với nhiều thứ tự (ví dụ như một thể hiện của NSMutableArray) có chứa các dòng con lồng nhau trực tiếp cho hàng nhất định.

  • @ "displayValues" Một quan hệ nhiều thứ tự có chứa giá trị hiển thị cho hàng.

  • @ "tiêu chí" Một mối quan hệ nhiều thứ tự có chứa tiêu chí cho hàng.

Bất kỳ ai cũng có thể đưa ra ví dụ về cách thực hiện việc này?

Trả lời

2

=========== 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.

+0

Đá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. –

+0

@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ờ –

Các vấn đề liên quan