简体   繁体   中英

Why am I getting an “unrecognized selector sent to class” error for CIFilter?

This code works on an iPad 2 simulator, but not on my physical iPad 2 (which is running on iOS 7.0.6):

var fade = CIFilter(name: "CIExposureAdjust", withInputParameters:["inputEV" : -2.0 ])

The full error message says:

[CIFilter filterWithName:withInputParameters:]: unrecognized selector sent to class 0x392d8d9c 2015-07-05 23:12:37.106 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CIFilter filterWithName:withInputParameters:]: unrecognized selector sent to class 0x392d8d9c'

Check the official documentation of + filterWithName:withInputParameters:

+ filterWithName:withInputParameters:

Availability
Available in iOS 8.0 and later.

Since your iPad is running on iOS 7, this method is not available, and therefore your app crashes.

A few possible solutions:

  1. Use - respondsToSelector: to check if the method exists.

  2. Check if the current foundation version number, NSFoundationVersionNumber is higher than NSFoundationVersionNumber_iOS_7_1 .

  3. Make iOS 8 a minimum requirement for your app.

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