简体   繁体   中英

CIFilter determine inputKey parameter type at runtime

We get the input keys for a CIFilter by calling [filter inputKeys] which returns an array of keys. Is there a recommended way of determining, at runtime, the input parameter type for a specific key?

Having the input keys you can use this as key for the attributes dictionary, which should deliver a type information for every input key:

for( NSString* inputKey in filter.inputKeys ) 
{
   NSDictionary *attribute = filter.attributes[inputKey];
   NSString *inputKeyClassName = attribute[kCIAttributeClass];
   NSLog(@"%@: %@", inputKey, inputKeyClassName);
}

Output for CIColorControl:

2013-05-13 23:30:27.615 cifilter[7918:303] inputImage: CIImage
2013-05-13 23:30:27.616 cifilter[7918:303] inputSaturation: NSNumber
2013-05-13 23:30:27.616 cifilter[7918:303] inputBrightness: NSNumber
2013-05-13 23:30:27.616 cifilter[7918:303] inputContrast: NSNumber

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM