我们通过调用[filter inputKeys]来获取CIFilter的输入键,它返回一个键数组。是否有建议的方法在运行时确定特定键的输入参数类型?
答案 0 :(得分:4)
使用输入键可以将其用作属性字典的键,该字典应为每个输入键提供类型信息:
for( NSString* inputKey in filter.inputKeys )
{
NSDictionary *attribute = filter.attributes[inputKey];
NSString *inputKeyClassName = attribute[kCIAttributeClass];
NSLog(@"%@: %@", inputKey, inputKeyClassName);
}
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