Scripting bridge: make enums in predicates passable as integers

Originator:amorya
Number:rdar://19396987 Date Originated:07-Jan-2015 10:36 AM
Status:Open Resolved:
Product:OS X SDK Product Version:Mac OS X 10.10.1 (14B25)
Classification:Enhancement Reproducible:Always
 
There’s something of a mismatch between SBElementArray and NSArray with regards predicates. For example, on SBElementArray, in order to pass in an enum value to the predicate’s format string, I have to use NSAppleEventDescriptor like so:

	NSAppleEventDescriptor *active = [NSAppleEventDescriptor descriptorWithEnumCode:OFProjectStatusActive];
	NSAppleEventDescriptor *onHold = [NSAppleEventDescriptor descriptorWithEnumCode:OFProjectStatusOnHold];
	NSArray *filteredProjs = [ofProjs filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"status == %@ || status == %@", active, onHold]];

However, if I’ve already turned the SBElementArray into an NSArray (perhaps by calling -get, or by filtering it previously), I would not use NSAppleEventDescriptor, and instead would just pass in the enum values as integers. This is a mismatch, the exact same predicate should be able to filter an NSArray or an SBElementArray. I suggest that you allow integers in both cases, and handle the wrapping into NSAppleEventDescriptors yourselves in the SBElementArray case.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!