CIFilter在运行时确定inputKey参数类型

时间:2013-05-13 21:08:37

标签: ios objective-c cocoa-touch core-image

我们通过调用[filter inputKeys]来获取CIFilter的输入键,它返回一个键数组。是否有建议的方法在运行时确定特定键的输入参数类型?

1 个答案:

答案 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