crash after accessing photo library using UIImagePickerController - ios

I am having troubles with accessing Photo Library when the button is tapped. Just as usual I am asking if it is accessible. Below is my code
#IBAction func photoLibraryButtonTapped(sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.allowsEditing = true
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}
And here is what Xcode says:
2016-08-08 23:05:11.209 Auyrma[1799:20237892] -[UIViewController photoLibraryButtonTapped:]: unrecognized selector sent to instance 0x7fd3e9d39ed0
2016-08-08 23:05:11.214 Auyrma[1799:20237892] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController photoLibraryButtonTapped:]: unrecognized selector sent to instance 0x7fd3e9d39ed0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000113fdcd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000113a50deb objc_exception_throw + 48
2 CoreFoundation 0x0000000113fe5d3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000113f2bcfa ___forwarding___ + 970
4 CoreFoundation 0x0000000113f2b8a8 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001124d6a8d -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x0000000112649e67 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x000000011264a143 -[UIControl _sendActionsForEvents:withEvent:] + 327
8 UIKit 0x0000000112649263 -[UIControl touchesEnded:withEvent:] + 601
9 UIKit 0x000000011254999f -[UIWindow _sendTouchesForEvent:] + 835
10 UIKit 0x000000011254a6d4 -[UIWindow sendEvent:] + 865
11 UIKit 0x00000001124f5dc6 -[UIApplication sendEvent:] + 263
12 UIKit 0x00000001124cf553 _UIApplicationHandleEventQueue + 6660
13 CoreFoundation 0x0000000113f02301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x0000000113ef822c __CFRunLoopDoSources0 + 556
15 CoreFoundation 0x0000000113ef76e3 __CFRunLoopRun + 867
16 CoreFoundation 0x0000000113ef70f8 CFRunLoopRunSpecific + 488
17 GraphicsServices 0x00000001164bcad2 GSEventRunModal + 161
18 UIKit 0x00000001124d4f09 UIApplicationMain + 171
19 Auyrma 0x000000010e1c2d82 main + 114
20 libdyld.dylib 0x0000000114e8492d start + 1
21 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

1.Please check target of your view controller and storyboard files should be in same target.
2.select your xib and remove your class which is mapped to that storyboard and map it back and press enter once you paste your class your nib name keep same for testing.
3.If this button is loading form custom view to view controller need to check that custom views are added to right target and re-map touch up inside with ibaction again.
This is what I could figure it out by see your conversations.

I have solved my problem this way:
Open up the Utilites
Open the Identity Inspector
Provide the class name again (however it was there already)
It seems like it was a bug of Xcode...

Related

Error while Changing the image of the button from an image to another when clicked on the button

Here is my code :
#IBAction func moreClicked(_ sender: UIButton) {
if sender.currentImage == #imageLiteral(resourceName: "more_off"){
sender.setImage(#imageLiteral(resourceName: "more_on"), for: .normal)
}
else
{
sender.setImage(#imageLiteral(resourceName: "more_off"), for: .normal)
}
}
I am getting this error:
2018-09-05 11:03:28.708661+0530 musicPlayer[25450:590989]
-[musicPlayer.SecondViewController more:]: unrecognized selector sent to instance 0x7fc1d4606d00
2018-09-05 11:03:28.715659+0530 musicPlayer[25450:590989] *
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason:
'-[musicPlayer.SecondViewController more:]: unrecognized selector sent
to instance 0x7fc1d4606d00'
* First throw call stack: ( 0 CoreFoundation 0x00000001087ea1e6 exceptionPreprocess + 294 1 libobjc.A.dylib
0x0000000107a36031 objc_exception_throw + 48 2 CoreFoundation
0x000000010886b784 -[NSObject(NSObject) doesNotRecognizeSelector:] +
132 3 UIKit 0x0000000108e956db
-[UIResponder doesNotRecognizeSelector:] + 295 4 CoreFoundation 0x000000010876c898 ___forwarding_ + 1432 5 CoreFoundation
0x000000010876c278 _CF_forwarding_prep_0 + 120 6 UIKit
0x0000000108c683e8 -[UIApplication sendAction:to:from:forEvent:] + 83
7 UIKit 0x0000000108de37a4
-[UIControl sendAction:to:forEvent:] + 67 8 UIKit 0x0000000108de3ac1 -[UIControl _sendActionsForEvents:withEvent:] + 450
9 UIKit 0x0000000108de2a09
-[UIControl touchesEnded:withEvent:] + 580 10 UIKit 0x0000000108cdd0bf -[UIWindow _sendTouchesForEvent:] + 2729 11 UIKit
0x0000000108cde7c1 -[UIWindow sendEvent:] + 4086 12 UIKit
0x0000000108c82310 -[UIApplication sendEvent:] + 352 13 UIKit
0x00000001095c36af dispatchPreprocessedEventFromEventQueue + 2796
14 UIKit 0x00000001095c62c4
__handleEventQueueInternal + 5949 15 CoreFoundation 0x000000010878cbb1
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 16 CoreFoundation 0x00000001087714af
__CFRunLoopDoSources0 + 271 17 CoreFoundation 0x0000000108770a6f __CFRunLoopRun + 1263 18 CoreFoundation
0x000000010877030b CFRunLoopRunSpecific + 635 19 GraphicsServices
0x000000010ff76a73 GSEventRunModal + 62 20 UIKit
0x0000000108c67057 UIApplicationMain + 159 21 musicPlayer
0x000000010711cc27 main + 55 22 libdyld.dylib
0x000000010cd4f955 start + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException
2018-09-05 11:03:28.708661+0530 musicPlayer[25450:590989]
-[musicPlayer.SecondViewController more:]: unrecognized selector sent to instance 0x7fc1d4606d00
The above message means that SecondViewController expects to have method called more: but when the action is triggered and instance from this class tries to find the more: method, it does not recognise such method and the application crashes.
What I think has happened here is: you have dragged action from your Xib/Storyboard to your VC class and named it more:. After this you have renamed it manually (not Refactor > Rename) to moreClicked:. This way the IBAction of the SecondViewController still points to method that is called more:, however your class does not have such method anymore.
So basically, you need to remove the already existing reference of the IBAction from your xib/storyboard and reconnect it with the new method: moreClicked:, and all should be working.

Swift: Not able to navigate to another view controller

I really do not know what mistake am I doing in the following lines:
// Instantiate SecondViewController
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "RegistrationScreen2View") as! RegistrationScreen2ViewController
self.navigationController?.pushViewController(secondViewController, animated: true)
I am not able to move to second view controller in the story board I have mentioned story board id as RegistrationScreen2View for RegistrationScreen2ViewController.
I am getting the following exception:
2016-10-24 11:26:16.607 toadways[965:11142] -[toadways.RegistrationScreen1ViewController continue]: unrecognized selector sent to instance 0x7fe05dc34ec0
2016-10-24 11:26:16.619 toadways[965:11142] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[toadways.RegistrationScreen1ViewController continue]: unrecognized selector sent to instance 0x7fe05dc34ec0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010efa534b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ea0621e objc_exception_throw + 48
2 CoreFoundation 0x000000010f014f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010ef2ac15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010ef2a798 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010f3cab88 -[UIApplication sendAction:to:from:forEvent:] + 83
6 UIKit 0x000000010f5502b2 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x000000010f5505cb -[UIControl _sendActionsForEvents:withEvent:] + 444
8 UIKit 0x000000010f54f4c7 -[UIControl touchesEnded:withEvent:] + 668
9 UIKit 0x000000010f4380d5 -[UIWindow _sendTouchesForEvent:] + 2747
10 UIKit 0x000000010f4397c3 -[UIWindow sendEvent:] + 4011
11 UIKit 0x000000010f3e6a33 -[UIApplication sendEvent:] + 371
12 UIKit 0x000000010fbd8b6d __dispatchPreprocessedEventFromEventQueue + 3248
13 UIKit 0x000000010fbd1817 __handleEventQueue + 4879
14 CoreFoundation 0x000000010ef4a311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 CoreFoundation 0x000000010ef2f59c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x000000010ef2ea86 __CFRunLoopRun + 918
17 CoreFoundation 0x000000010ef2e494 CFRunLoopRunSpecific + 420
18 GraphicsServices 0x0000000116c0ca6f GSEventRunModal + 161
19 UIKit 0x000000010f3c8f34 UIApplicationMain + 159
20 toadways 0x000000010e2318bf main + 111
21 libdyld.dylib 0x000000011266368d start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Please let me know what mistake am I doing.
Your code should work. The most possibility is that you forgot to input an Storyboard ID for your destination ViewController.
***How to Fix:
In the Identity Inspector of destination ViewController, enter its ID.

segmented control - unrecognized selector sent to instance

I want to use sender to get the value from segmented control, but I am getting the unrecognized selector sent to instance error. The segmented control was added within a view. I've tried removing the semicolon and/or sender and none of the prior posts I've found seem to help. Any ideas?
Swift Code
var segCntrl = UISegmentedControl(items: ["Yes","No"])
segCntrl.tag = 100
segCntrl.center = CGPointMake(qView.bounds.width/2, qView.bounds.minY+40)
self.qView.addSubview(segCntrl)
func segmentorSwitch(sender: AnyObject) {
if(sender.selectedSegmentIndex == 1) {
println("Yes selected")
}
else if(sender.selectedSegmentIndex == 2) {
println("No selected")
}
}
segCntrl.addTarget(self, action: "segmentorSwitch:", forControlEvents: UIControlEvents.ValueChanged)
Error code:
2015-07-07 11:46:24.482 myApp [75641:1855377] -[[myApp.SegViewControllerr segmentorSwitch:]: unrecognized selector sent to instance 0x7fbb0a43b450
2015-07-07 11:46:24.489 myApp[75641:1855377] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myApp.SegViewController segmentorSwitch:]: unrecognized selector sent to instance 0x7fbb0a43b450'
* First throw call stack:
(
0 CoreFoundation 0x00000001060dcc65 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010838abb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001060e40ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010603a13c ___forwarding_ + 988
4 CoreFoundation 0x0000000106039cd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001070bfd62 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x00000001071d150a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x000000010724dfba -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 570
8 UIKit 0x000000010724ffbf -[UISegmentedControl touchesEnded:withEvent:] + 143
9 UIKit 0x000000010710c958 -[UIWindow _sendTouchesForEvent:] + 735
10 UIKit 0x000000010710d282 -[UIWindow sendEvent:] + 682
11 UIKit 0x00000001070d3541 -[UIApplication sendEvent:] + 246
12 UIKit 0x00000001070e0cdc _UIApplicationHandleEventFromQueueEvent + 18265
13 UIKit 0x00000001070bb59c _UIApplicationHandleEventQueue + 2066
14 CoreFoundation 0x0000000106010431 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
15 CoreFoundation 0x00000001060062fd __CFRunLoopDoSources0 + 269
16 CoreFoundation 0x0000000106005934 __CFRunLoopRun + 868
17 CoreFoundation 0x0000000106005366 CFRunLoopRunSpecific + 470
18 GraphicsServices 0x000000010cc5ba3e GSEventRunModal + 161
19 UIKit 0x00000001070be8c0 UIApplicationMain + 1282
20 myApp 0x0000000104d9a0c7 main + 135
21 libdyld.dylib 0x0000000109458145 start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Looks like segmentorSwitch: is implemented inside another method. Define it outside the method in which your code is contained, and this should be fixed.

iOS - Unable to locate the location of Exception

What is happening?
I am getting an exception in a program where a function is to be called On a Button tap on a custom view within contentView of a UItableViewCell
What i have tried?
1) I tried to add a Global Exception point in the Breakpoints Navigator
2) Checked Zombie Detection from Instruments
3) Breakpoints in the functions that should be called
Crash Log that i receive?
-[UIImageView nextPage:]: unrecognized selector sent to instance 0xa7d5f20
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView nextPage:]: unrecognized selector sent to instance 0xa7d5f20'
*** First throw call stack:
(
0 CoreFoundation 0x023e11e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01fc98e5 objc_exception_throw + 44
2 CoreFoundation 0x0247e243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x023d150b ___forwarding___ + 1019
4 CoreFoundation 0x023d10ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x01fdb880 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x009463b9 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x00946345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x00a47bd1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00a47fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00a47243 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x00cdc2e3 _UIGestureRecognizerUpdate + 7166
12 UIKit 0x00985a5a -[UIWindow _sendGesturesForEvent:] + 1291
13 UIKit 0x00986971 -[UIWindow sendEvent:] + 1021
14 UIKit 0x009585f2 -[UIApplication sendEvent:] + 242
15 UIKit 0x00942353 _UIApplicationHandleEventQueue + 11455
16 CoreFoundation 0x0236a77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
17 CoreFoundation 0x0236a10b __CFRunLoopDoSources0 + 235
18 CoreFoundation 0x023871ae __CFRunLoopRun + 910
19 CoreFoundation 0x023869d3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x023867eb CFRunLoopRunInMode + 123
21 GraphicsServices 0x0381a5ee GSEventRunModal + 192
22 GraphicsServices 0x0381a42b GSEventRun + 104
23 UIKit 0x00944f9b UIApplicationMain + 1225
24 IslamBox 0x000029bc main + 76
25 libdyld.dylib 0x034b3701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What else could i do as the functions are registered in the Nib file?
UPDATE: as the log says -[UIImageView nextpage] is unrecognized however the next page is in the ViewController. as the custom view is the ViewController's view added to the cell's contentView.
I need to retain my ViewController , or keep a strong reference to it if using ARC. If I assign it to cell.contentView as a local variable, it's not going to be around any more when nextPage: gets called. (The error shows that its memory has been released and re-used for a different type of object.)
Could it be just the fact that the object in your xib file is set as UIImageView instead of your own custom subclass of UIImageView ?
When the view is allocated from your xib, it will be a UIImageView. Having it linked to something different in your .h or .m won't change that.
Change it here :
if every time crash on [UIImageView nextPage:],
you can try
#implementation UIImageView(Test)
- (id)nextPage:(id)noUse
{
return nil;
}
#end
and set a breakpoint on the return.

Unrecognized selector sent to instance, Storyboard bug after connecting a button to view controller

I was messing with my storyboard with no code involved and got this error after I connected "Terms of use" button to a view controller. It was working fine before this action.
-I created and connected a class to Terms of Use View Controller
-I used action push segue to connect
2014-01-22 17:26:45.434 Project[1162:a0b] -[AboutViewController termsOfUseButton:]: unrecognized selector sent to instance 0x8c89d40
2014-01-22 17:26:45.437 Project[1162:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AboutViewController termsOfUseButton:]: unrecognized selector sent to instance 0x8c89d40'
*** First throw call stack:
(
0 CoreFoundation 0x0173b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014be8b6 objc_exception_throw + 44
2 CoreFoundation 0x017d8903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172b90b ___forwarding___ + 1019
4 CoreFoundation 0x0172b4ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x014d0874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022e0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022e04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003260c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00326484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00325733 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x0026b51d -[UIWindow _sendTouchesForEvent:] + 852
12 UIKit 0x0026c184 -[UIWindow sendEvent:] + 1232
13 UIKit 0x0023fe86 -[UIApplication sendEvent:] + 242
14 UIKit 0x0022a18f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x016c483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x016c41cb __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x016e129e __CFRunLoopRun + 910
18 CoreFoundation 0x016e0ac3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x016e08db CFRunLoopRunInMode + 123
20 GraphicsServices 0x036909e2 GSEventRunModal + 192
21 GraphicsServices 0x03690809 GSEventRun + 104
22 UIKit 0x0022cd3b UIApplicationMain + 1225
23 Project 0x00003a9d main + 141
24 libdyld.dylib 0x01d77725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
(Lame but I found the solution after I finished writing the question)
The reason for this error is I created an IBAction-UIButton method on touch up inside.
I deleted that code and hoped the traces were deleted.
It seems it wasnt, I had to unconnect the touch up inside by clicking the X in red squared spot.
I would try recreating the button and the segue, maybe you changed the IBOutlet name by accident or any other thing.
GL HF

Resources