There is very little documentation on NSRuleEditor. :(
First, you need to distinguish between a 'criterion' and a 'display value' although they may be the same kind of classes. The criterion is a kind of identifier and the display value is what is actually shown.

It is also helpful to think of the rule editor as displaying a tree of alternatives along each row. The left-most criterion is the root, typically a NSPopupButton. The selected NSMenuItem presents a particular branch. So if a criterion is a NSPopupButton then 'child:' might be the 'target' of the NSMenuItem at the 'index' in the criterion's menu. (criterion)NSPopUpButton => NSMenuItem target => next NSControl (the child, perhaps another NSPopUpButton)

The 'child:' method returns a criterion that can be a variety objects a NSControl, a NSMenuItem, a NSString, an NSView, or nil. - (id) ruleEditor:(NSRuleEditor *)editor child:(NSInteger)index forCriterion:(id)criterion withRowType:(NSRuleEditorRowType)rowType;

How you chose to chain along the criteria depends on you. The sequence of criteria represent paths through the rule tree.

If the initial criterion is nil then you are at the root and your root criterion might be a function, perhaps, of the row-type.

The 'displayValue' is what actually populates the rule editor and is either a NSMenuItem, NSString, an NSView, or some kind of NSControl. In some cases if the criterion happens to be a NSMenuItem then the display value may just be a copy of the criterion, or a copy of the 'title' string, but each 'display value' must be new. We cannot just return a pointer to the criterion. In any case, the 'display value' is derived from the particular criterion and must be a new value for each invocation of - (id) ruleEditor:(NSRuleEditor *)editor displayValueForCriterion: (id)criterion inRow:(NSInteger)row;

Any how, what I've learned about NSRuleEditor is just the result of spending too much time building rule editors. I am sorry but I don't have a good example project to demonstrate this.

In summary, the criteria represent a model or prototype of the alternative paths through the selection tree and the display values represent an instantiation of the path.

Anyway, this is what I've learned just by treating a rule editor as a black box maybe someone else can provide an authoritative answer.

Good luck.
*-------------------------------------------------
* Stop spam before it gets to your mailbox! Support blocklists.
* I use http://www.spamcop.net/.
* my PGP key id: 0x63fa758 keyserver: http://keyserver1.pgp.com
*/

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to