Swift app crashes with `unrecognized selector sent to instance` on CLLocationManager - ios

Similar to many, many other questions on StackOverflow, I get a unrecognized selector sent to instance fault, when running my app. What makes my case different (I think) is that it is written in Swift and that the common reason is not the reason here.
In this question the solution is to set the "Custom Class" in the Identity Inspector for that view to the responding class. I checked this and this is the case (note that I did rename the class at some point, but it now is definitely set to "ViewController").
I include the stack trace below as well as the code for ViewController.swift. You can also find all of the code here. I managed to avoid this problem by starting fresh, which enabled me to solve my earlier question. This new trial can be found in this branch. But, I want to know what is wrong and solve this.
Some thought
One question that I couldn't answer successfully is whether CLLocationManagerDelegate needs some required methods? But because I got it to work in the other branch, I suspect it's not necessary.
2014-07-03 21:50:26.056 RowingTracker2[11416:60b] -[CLLocationManager requestWhenInUseAuthorization]: unrecognized selector sent to instance 0xa10c4a0
2014-07-03 21:50:26.059 RowingTracker2[11416:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CLLocationManager requestWhenInUseAuthorization]: unrecognized selector sent to instance 0xa10c4a0'
*** First throw call stack:
(
0 CoreFoundation 0x008831e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01e2a8e5 objc_exception_throw + 44
2 CoreFoundation 0x00920243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0087350b ___forwarding___ + 1019
4 CoreFoundation 0x008730ee _CF_forwarding_prep_0 + 14
5 RowingTracker2 0x00003352 _TFC14RowingTracker214ViewController11viewDidLoadfS0_FT_T_ + 738
6 RowingTracker2 0x000033a2 _TToFC14RowingTracker214ViewController11viewDidLoadfS0_FT_T_ + 34
7 UIKit 0x0102f33d -[UIViewController loadViewIfRequired] + 696
8 UIKit 0x0102f5d9 -[UIViewController view] + 35
9 UIKit 0x00f4f267 -[UIWindow addRootViewControllerViewIfPossible] + 66
10 UIKit 0x00f4f5ef -[UIWindow _setHidden:forced:] + 312
11 UIKit 0x00f4f86b -[UIWindow _orderFrontWithoutMakingKey] + 49
12 UIKit 0x00f5a3c8 -[UIWindow makeKeyAndVisible] + 65
13 UIKit 0x00f0abc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
14 UIKit 0x00f0f667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
15 UIKit 0x00f23f92 -[UIApplication handleEvent:withNewEvent:] + 3517
16 UIKit 0x00f24555 -[UIApplication sendEvent:] + 85
17 UIKit 0x00f11250 _UIApplicationHandleEvent + 683
18 GraphicsServices 0x031fff02 _PurpleEventCallback + 776
19 GraphicsServices 0x031ffa0d PurpleEventCallback + 46
20 CoreFoundation 0x007feca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
21 CoreFoundation 0x007fe9db __CFRunLoopDoSource1 + 523
22 CoreFoundation 0x0082968c __CFRunLoopRun + 2156
23 CoreFoundation 0x008289d3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x008287eb CFRunLoopRunInMode + 123
25 UIKit 0x00f0ed9c -[UIApplication _run] + 840
26 UIKit 0x00f10f9b UIApplicationMain + 1225
27 RowingTracker2 0x00008021 top_level_code + 97
28 RowingTracker2 0x0000805b main + 43
29 libdyld.dylib 0x024ff701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
ViewController.swift
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
#IBOutlet var mapview: MKMapView = nil
var locationmgr : CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
locationmgr = CLLocationManager()
locationmgr.delegate = self
locationmgr.requestWhenInUseAuthorization() ///< Offending line.
// mapview.showsUserLocation = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

As requestWhenInUseAuthorization method is only available on iOS 8 (according to Apple Documentation) you have to wrap it:
Swift code:
if (locationmgr.respondsToSelector(Selector("requestWhenInUseAuthorization"))) {
locationmgr.requestWhenInUseAuthorization()
}
And the same for Objective-C:
if ([locationmgr respondsToSelector:#selector(requestWhenInUseAuthorization)]) {
[locationmgr requestWhenInUseAuthorization];
}

This code won't run on iOS 7 and below - according the docs, requestWhenInUseAuthorization is only available on iOS 8:
Availability:
Available in iOS 8.0 and later.

Here is what I'm using to support the new core location method in iOS 7 with no errors:
SEL requestSelector = NSSelectorFromString(#"requestWhenInUseAuthorization");
if ([locationManager respondsToSelector:requestSelector]) {
[locationManager performSelector:requestSelector withObject:NULL];
}

Similarly, if you're seeing this error in relation to CLLocationManager, check that you are not attempting to use the authorizationStatus property on an iOS version prior to iOS14.
https://developer.apple.com/documentation/corelocation/cllocationmanager/3563952-authorizationstatus

Related

Swift button error on iOS app but not in playground

I am trying to learn swift to make free educational app for my country.
I know only the basics of programming and swift, but I am trying to understand iOS development.
I think I am having a problem with scope, but not sure what to do.
With didMoveToView being (the required) according to books I read, I can't compile and execute the code. So, when I run it in Xcode iOS App Project, my App crashes (even though it works in playground).
The code:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
class fooo {
static var bar = "hello world!"
#IBAction func hello_button(sender: AnyObject) {
print(fooo.bar)
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Below is the Crash log (Occurs on button touch):
2016-08-26 07:22:00.512 k[2074:37791] -[k.ViewController hello_button:]: unrecognized selector sent to instance 0x7aa2e670
2016-08-26 07:22:00.521 k[2074:37791] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[k.ViewController hello_button:]: unrecognized selector sent to instance 0x7aa2e670'
*** First throw call stack:
(
0 CoreFoundation 0x00200494 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01f17e02 objc_exception_throw + 50
2 CoreFoundation 0x0020a253 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0013f89d ___forwarding___ + 1037
4 CoreFoundation 0x0013f46e _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x01f2c0b5 -[NSObject performSelector:withObject:withObject:] + 84
6 UIKit 0x009f2e38 -[UIApplication sendAction:to:from:forEvent:] + 118
7 UIKit 0x009f2db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
8 UIKit 0x00b96f3b -[UIControl sendAction:to:forEvent:] + 79
9 UIKit 0x00b972d4 -[UIControl _sendActionsForEvents:withEvent:] + 433
10 UIKit 0x00b962c1 -[UIControl touchesEnded:withEvent:] + 714
11 UIKit 0x00a7352e -[UIWindow _sendTouchesForEvent:] + 1095
12 UIKit 0x00a745cc -[UIWindow sendEvent:] + 1159
13 UIKit 0x00a15be8 -[UIApplication sendEvent:] + 266
14 UIKit 0x009ea769 _UIApplicationHandleEventQueue + 7795
15 CoreFoundation 0x00112e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x00108aeb __CFRunLoopDoSources0 + 523
17 CoreFoundation 0x00107f08 __CFRunLoopRun + 1032
18 CoreFoundation 0x00107846 CFRunLoopRunSpecific + 470
19 CoreFoundation 0x0010765b CFRunLoopRunInMode + 123
20 GraphicsServices 0x04717664 GSEventRunModal + 192
21 GraphicsServices 0x047174a1 GSEventRun + 104
22 UIKit 0x009f0eb9 UIApplicationMain + 160
23 k 0x00012581 main + 145
24 libdyld.dylib 0x02935a25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You're right, the issue is scope (assuming you connected your button properly as others mentioned):
import UIKit
class ViewController: UIViewController {
class fooo {
var bar = "hello world!"
func mSayBar() { print(self.bar)}
}
var foo = fooo()
#IBAction func hello_button(sender: AnyObject) {
foo.mSayBar()
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
viewDidLoad is it's own local scope--it doesn't extend any further than the end brace " } "
After the first (millisecond?) everything declared in VDL is no longer alive; thus, it is best for initializing or calling, not declaring.
To declare global, just put everything in a new swift file, or put it outside ALL class scopes. Swift makes global scope easy (but be careful)
You said viewDidLoad is required, which is true, but only for setting up the program. Most of your logic / functions go outside of viewDidLoad
unrecognized selector sent to instance 0x7aa2e670 means that the button has been linked to an IBAction outlet that isn't defined in your code. Go to your ViewController's Storyboard mode, and right click the button in the subview list. Check if there is an outlet for the Touch Up Inside event and if it has the same name as the function in your code that you want to call (in your case it's hello_button.
Here's a picture if you didn't understand the above paragraph.

Swift NSUnknownKeyException FoodTracker

I'm just beginning to learn swift, and I have trouble understanding what the console is trying to tell me with this error. I'm following the Apple's guide to learn swift and in the section "Connect the UI to Code" I'm having the following problem:
2016-02-22 01:06:54.121 FoodTracker[20300:502503] <CATransformLayer: 0x7fab3973cb90> - changing property contentsCenter in transform-only layer, will have no effect
2016-02-22 01:06:54.127 FoodTracker[20300:502503] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FoodTracker.ViewController 0x7fab394a9a00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setDefaultLabelText.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001040b7e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000105df7deb objc_exception_throw + 48
2 CoreFoundation 0x00000001040b7aa9 -[NSException raise] + 9
3 Foundation 0x00000001044809bb -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000104a63320 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x0000000104c91f41 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000103ff84a0 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x0000000104c90924 -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000104a69eea -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000104a6a816 -[UIViewController loadView] + 178
10 UIKit 0x0000000104a6ab74 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000104a6b2e7 -[UIViewController view] + 27
12 UIKit 0x0000000104941ab0 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000104942199 -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000104953c2e -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x00000001048cc663 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x00000001048d2cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
17 UIKit 0x00000001048cfe7b -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x0000000107c8c754 -[FBSSerialQueue _performNext] + 192
19 FrontBoardServices 0x0000000107c8cac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
20 CoreFoundation 0x0000000103fe3a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x0000000103fd995c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x0000000103fd8e13 __CFRunLoopRun + 867
23 CoreFoundation 0x0000000103fd8828 CFRunLoopRunSpecific + 488
24 UIKit 0x00000001048cf7cd -[UIApplication _run] + 402
25 UIKit 0x00000001048d4610 UIApplicationMain + 171
26 FoodTracker 0x0000000103ed947d main + 109
27 libdyld.dylib 0x000000010690092d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Also, this is the code I'm running:
import UIKit
class ViewController: UIViewController {
//MARK: Propierties
#IBOutlet weak var nameTextField: UITextField!
#IBOutlet weak var mealNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
//MARK: Actions
#IBAction func setDefaultLabelText(sender: UIButton) {
mealNameLabel.text = "Default Text"
}
}
Thank you in advance for your help. Looking forward to it.
Already solved my problem. As I was just starting to code, I tried copying and pasting what I've written into a new file and it works perfectly now. No issues at all. It might have been some bug with the config. Thanks anyway.

Several errors when running my first iOS app

I'm able to run the app initially (no visible errors), but when I input a number in the ageBox area and press the getAge button, I get several errors.
Here is the code:
import UIKit
class ViewController: UIViewController {
#IBOutlet var ageBox: UITextField!
#IBAction func getAge(sender: AnyObject) {
println(ageBox.text)
}
#IBOutlet var answerLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Here is the error I get:
2015-04-21 10:36:24.183 Cat Years[5284:2484424] Can't find keyplane
that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad;
using 2705787216_PortraitChoco_iPhone-Simple-Pad_Default
2015-04-21 10:36:25.826 Cat Years[5284:2484424] Can't find keyplane
that supports type 4 for keyboard iPhone-PortraitChoco-NumberPad;
using 2705787216_PortraitChoco_iPhone-Simple-Pad_Default
5
2015-04-21 10:36:27.067 Cat Years[5284:2484424]
-[Cat_Years.ViewController getAgeButton:]: unrecognized selector sent to instance 0x7fc881e287f0
2015-04-21 10:36:27.078 Cat Years[5284:2484424] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason:
'-[Cat_Years.ViewController getAgeButton:]: unrecognized selector sent
to instance 0x7fc881e287f0'
*** First throw call stack:
(
0 CoreFoundation 0x00000001044c5c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000106030bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001044cd0ad -[NSObject(NSObject)
doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010442313c forwarding + 988
4 CoreFoundation 0x0000000104422cd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000104d65da2 -[UIApplication
sendAction:to:from:forEvent:] + 75
6 UIKit 0x0000000104e7754a -[UIControl
_sendActionsForEvents:withEvent:] + 467
7 UIKit 0x0000000104e76919 -[UIControl touchesEnded:withEvent:] + 522
8 UIKit 0x0000000104db2998 -[UIWindow _sendTouchesForEvent:] + 735
9 UIKit 0x0000000104db32c2 -[UIWindow sendEvent:] + 682
10 UIKit 0x0000000104d79581 -[UIApplication sendEvent:] + 246
11 UIKit 0x0000000104d86d1c _UIApplicationHandleEventFromQueueEvent +
18265
12 UIKit 0x0000000104d615dc _UIApplicationHandleEventQueue + 2066
13 CoreFoundation 0x00000001043f9431
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
14 CoreFoundation 0x00000001043ef2fd __CFRunLoopDoSources0 + 269
15 CoreFoundation 0x00000001043ee934 __CFRunLoopRun + 868
16 CoreFoundation 0x00000001043ee366 CFRunLoopRunSpecific + 470
17 GraphicsServices 0x00000001084aca3e GSEventRunModal + 161
18 UIKit 0x0000000104d64900 UIApplicationMain + 1282
19 Cat Years 0x00000001042c8007 main + 135
20 libdyld.dylib 0x0000000106788145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type
NSException
Any ideas?
Copied your code to a new project. Added a text box, switch, and label. Did the connections. Added constraints using "Add Missing Constraints". And it all worked (with no modification to your view controller code). Here is the link:
Project
The possibilities I can think of (based on errors I made when I started): (1) in changing connections while editing the storyboard I found that deleted controls are not automatically deleted in the xml file. Suggest you look in the connections editor to see if there are controls that you deleted. (2) do a "clean" to make sure.
Good luck
For the keyplane error,try this:
For reference:see this
iOS Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard
so that the entry is UNchecked then the software keyboard will be displayed once again.
For the NSInvalidArgumentException',try this:
#IBAction func getAge(sender: UIButton) {
println(ageBox.text)
}

Don't know why my app is crashing [duplicate]

This question already has answers here:
setValue:forUndefinedKey: this class is not key value coding-compliant for the key [duplicate]
(20 answers)
Closed 7 years ago.
I am very new to swift, extremely new, and I will probably feel like an idiot for asking this question. My very simple goal is that when my button is tapped the button's title will disappear, but unfortunately the app is crashing every time I run it and I don't know what I'm doing wrong. Thank you for the help.
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var background1: UIImageView!
#IBOutlet weak var screenButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.screenButton.setTitle("Tap!", forState: UIControlState.Normal)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func screenTapped(sender: AnyObject) {
self.screenButton.setTitle("", forState: UIControlState.Normal)
}
}
2015-04-10 17:13:41.465 TopScore[6391:414281] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key screenTapped.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000104fc0a75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000106b18bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000104fc06b9 -[NSException raise] + 9
3 Foundation 0x00000001053dbd43 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000104f0a5e0 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x0000000105b1a4ed -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x0000000105978a88 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x0000000105979078 -[UIViewController loadView] + 109
8 UIKit 0x00000001059792e9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010597977e -[UIViewController view] + 27
10 UIKit 0x0000000105898509 -[UIWindow addRootViewControllerViewIfPossible] + 58
11 UIKit 0x00000001058988a1 -[UIWindow _setHidden:forced:] + 247
12 UIKit 0x00000001058a4f8c -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x000000010584f0c2 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
14 UIKit 0x0000000105851e3e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
15 UIKit 0x0000000105850d35 -[UIApplication workspaceDidEndTransaction:] + 179
16 FrontBoardServices 0x00000001086ca243 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
17 CoreFoundation 0x0000000104ef5c7c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18 CoreFoundation 0x0000000104eeb9c5 __CFRunLoopDoBlocks + 341
19 CoreFoundation 0x0000000104eeb785 __CFRunLoopRun + 2389
20 CoreFoundation 0x0000000104eeabc6 CFRunLoopRunSpecific + 470
21 UIKit 0x00000001058507a2 -[UIApplication _run] + 413
22 UIKit 0x0000000105853580 UIApplicationMain + 1282
23 TopScore 0x0000000104de1cee top_level_code + 78
24 TopScore 0x0000000104de1d2a main + 42
25 libdyld.dylib 0x00000001072f4145 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
At some point, you accidentally set up an outlet called screenTapped. You need to find that outlet in Interface Builder in your storyboard and delete it.
What you want is an action from the button to screenTapped:. An action and an outlet are two very different things.

libc++abi.dylib: terminating with uncaught exception of type NSException on iOS 7.1

I am new to programming. I am going to learning iOS app development with the Apple new programming language Swift.
And I follow this site( https://developer.apple.com/swift/blog/?id=16 ) to start.
I copied the code from the video into my Xcode project. Anything was fine when I run the app in iOS 8.1 iOS simulator.
BUT I got exception while I choose iOS 7.1 iOS simulator. And I put the app into my iPhone 5S(iOS 7.1.2), it CRASHED.
Below is the code I copied from the video:
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var photoImageView: UIImageView!
let context = CIContext(options: nil)
#IBAction func applyFilter(sender: AnyObject) {
let inputImage = CIImage(image: photoImageView.image)
let randomColor = [kCIInputAngleKey: (Double(arc4random_uniform(314)) / 100)]
let filteredImage = inputImage.imageByApplyingFilter("CIHueAdjust",withInputParameters: randomColor)
let renderedImage = context.createCGImage(filteredImage, fromRect: filteredImage.extent())
photoImageView.image = UIImage(CGImage: renderedImage)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Here is what I got from the console:
2014-11-03 16:17:30.645 njnj[2748:60b] -[CIImage imageByApplyingFilter:withInputParameters:]: unrecognized selector sent to instance 0x7fe4e3d165e0
2014-11-03 16:17:30.649 njnj[2748:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CIImage imageByApplyingFilter:withInputParameters:]: unrecognized selector sent to instance 0x7fe4e3d165e0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106c8b495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010852799e objc_exception_throw + 43
2 CoreFoundation 0x0000000106d1c65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000106c7cd8d ___forwarding___ + 973
4 CoreFoundation 0x0000000106c7c938 _CF_forwarding_prep_0 + 120
5 njnj 0x0000000106b934a0 _TFC4njnj14ViewController11applyFilterfS0_FPSs9AnyObject_T_ + 3648
6 njnj 0x0000000106b93a66 _TToFC4njnj14ViewController11applyFilterfS0_FPSs9AnyObject_T_ + 54
7 UIKit 0x000000010753af06 -[UIApplication sendAction:to:from:forEvent:] + 80
8 UIKit 0x000000010753af06 -[UIApplication sendAction:to:from:forEvent:] + 80
9 UIKit 0x000000010753aeb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
10 UIKit 0x0000000107617880 -[UIControl _sendActionsForEvents:withEvent:] + 203
11 UIKit 0x0000000107616dc0 -[UIControl touchesEnded:withEvent:] + 530
12 UIKit 0x0000000107571d05 -[UIWindow _sendTouchesForEvent:] + 701
13 UIKit 0x00000001075726e4 -[UIWindow sendEvent:] + 925
14 UIKit 0x000000010754a29a -[UIApplication sendEvent:] + 211
15 UIKit 0x0000000107537aed _UIApplicationHandleEventQueue + 9579
16 CoreFoundation 0x0000000106c1ad21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x0000000106c1a5f2 __CFRunLoopDoSources0 + 242
18 CoreFoundation 0x0000000106c3646f __CFRunLoopRun + 767
19 CoreFoundation 0x0000000106c35d83 CFRunLoopRunSpecific + 467
20 GraphicsServices 0x000000010baf2f04 GSEventRunModal + 161
21 UIKit 0x0000000107539e33 UIApplicationMain + 1010
22 njnj 0x0000000106b9582e top_level_code + 78
23 njnj 0x0000000106b9586a main + 42
24 libdyld.dylib 0x0000000108ee55fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I hope someone can help me solve this problem.
(Sorry for my poor English)
Usually "unrecognized selector sent to instance" (resulting from -doesNotRecognizeSelector:) indicates a memory management issue, often an over-release of an object that is still referenced somewhere.
I suggest you run a debug build with memory debugging to triage your app's memory issues. I suggest you use ASan through recent versions of Xcode. If that's not an option, you can use malloc history with guard malloc, scribble, and NSZombies.

Resources