I am getting this exception:
2012-10-11 14:27:05.039 SunriseAlarm[2297:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PickerViewController _setViewDelegate:]: unrecognized selector sent to instance 0x1e56fff0'
I have this code in the appDelegate.m file
PickerViewController *pvc = [[PickerViewController alloc] initWithNibName:#"PickerView" bundle:nil];
self.window.rootViewController = pvc;
I have already set the class of the nib to the custom class and it is not UIViewController. Please see image below.
Please let me know what do you think I am doing wrong.
Thank You,
Venkat Rao
You did set PickerViewController class for UIView, it's not correct, return back and set PickerViewController for File's owner
Related
I'm trying to pass data from my ViewController to TabBarController by using Objective-C. I'm trying to assign some data to "bottomTabEventList" (which is a property of my custom TabBarController class). Unfortunately, my program crashes by giving unrecognized selector instance error/warning.
In custom header of TabBarController class, named BottomTabview:
#interface BottomTabView : UITabBarController <UITabBarControllerDelegate>
#property(strong,nonatomic)EventList *bottomTabEventList;
#end
And prepareForSegue method in ViewController.m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
BottomTabView *btw = [segue destinationViewController];
//checking
if(btw == nil)
NSLog(#"btw in viewController is nil");
else
NSLog(#"btw in viewController is NOT nil");
if(self.eventList.eventList == nil)
NSLog(#"eventList in viewController is nil");
else
NSLog(#"eventList in viewController is NOT nil"); //end of checking
btw.bottomTabEventList = self.eventList; //This is where crash appears
}
Exact crash log is:
-[ViewController setBottomTabEventList:]: unrecognized selector sent to instance 0x7fe923c6ba00
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController setBottomTabEventList:]: unrecognized selector sent to instance 0x7fe923c6ba00'
Segue is from ViewController to BottomTabView and its type is "Present Modally". I'd really appreciate if you can help/guide me. Thanks in advance.
The problem seems to be that btw is not actually of type BottomTabView and is just a UIViewController hence the crash log giving:
[ViewController setBottomTabEventList:]: unrecognized selector sent to instance
As UIViewController does't know what BottomTabEventList is.
You need to make sure that btw is actually a BottomTabView instance.
Do a little introspection and I bet it will not go into this statement:
if ([btw isKindOfClass:[BottomTabView class]]){
btw.bottomTabEventList = self.eventList;
}
Im trying to integrate implement the project https://github.com/ariok/BWWalkthrough into my objective c project.
I have an objc bridging header that Xcode automatically made for me
I translated the ViewController.swift code as such
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Walkthrough" bundle:nil];
BWWalkthroughViewController *walkthrough = [sb instantiateViewControllerWithIdentifier:#"walk"];
BWWalkthroughPageViewController *page_zero = [sb instantiateViewControllerWithIdentifier:#"walk0"];
BWWalkthroughPageViewController *page_one = [sb instantiateViewControllerWithIdentifier:#"walk1"];
BWWalkthroughPageViewController *page_two = [sb instantiateViewControllerWithIdentifier:#"walk2"];
BWWalkthroughPageViewController *page_three = [sb instantiateViewControllerWithIdentifier:#"walk3"];
walkthrough.delegate = self;
[walkthrough addViewController:page_zero];
[walkthrough addViewController:page_one];
[walkthrough addViewController:page_two];
[walkthrough addViewController:page_three];
[self presentViewController:walkthrough animated:YES completion:nil];
and I import the swift classes like so:
import "SkipTheLine-Swift.h"
My bridging header file's name is "SkipTheLine-Bridging-Header.h"
now, when I run the code, I get this
2015-04-25 16:47:46.740 SkipTheLine[1631:215786] Unknown class BWWalkthroughViewController in Interface Builder file.
2015-04-25 16:47:46.754 SkipTheLine[1631:215786] -[UIViewController setDelegate:]: unrecognized selector sent to instance 0x12651cf90
2015-04-25 16:47:46.755 SkipTheLine[1631:215786] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setDelegate:]: unrecognized selector sent to instance 0x12651cf90'
* First throw call stack:
(0x1838aa530 0x19482c0e4 0x1838b15f4 0x1838ae3ac 0x1837b2c4c 0x10009c494 0x1880eca14 0x1880d5d08 0x1880ec3b0 0x1880ec03c 0x1880e5590 0x1880b8e60 0x18835846c 0x1880b73d0 0x183862d34 0x183861fd8 0x183860088 0x18378d1f4 0x18cbb76fc 0x18811e10c 0x10009e174 0x194eaaa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any ideas as to how I can use the swift code in interface builder?
Figured it out!
You just need to edit the MODULE in the interface builder to the name of the project!!
There are so many cases for "Unrecognized Selector Sent To Instance", I don't think I will find mine in so many threads. Or if I do it will take a month or so.
To be short. I receive this error, and my situation is:
I have a table view displaying recipes that are fetched from Core Data. When segue fires, it gets destination controller (which is UITabBarController), and provides a recipe for it.
The code for the segue method is:
if ([segue.identifier isEqualToString:#"RecipeTabBarController"]) {
RecipeTabBarController *VC = segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
Recipe *recipe = (Recipe*)[_controller objectAtIndexPath:indexPath];
VC.recipe = recipe;
}
TabBarController (which is the VC) has a property of a recipe, like so:
#property (nonatomic, strong) Recipe *recipe;
When I tap the cell, the segue fires, and the error occurs, with the following message from console:
2013-09-25 18:55:21.888 RecipeBank [974:60b] -[UITabBarController setRecipe:]: unrecognized selector sent to instance 0x15da8280
2013-09-25 18:55:21.892 RecipeBank [974:60b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController setRecipe:]: unrecognized selector sent to instance 0x15da8280'
First throw call stack:
(0x30583f53 0x3abec6af 0x305878e7 0x305861d3 0x304d5598 0x6676f 0x3319f6f1 0x665b7 0x32e1232b 0x32ec5253 0x32d75971 0x32ced473 0x3054f1d5 0x3054cb79 0x3054cebb 0x304b7ce7 0x304b7acb 0x35185283 0x32d59a41 0x67711 0x3b0f4ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
RecipeTabBarController imports Recipe class in header and TableViewController that's performing segue imports RecipeTabBarController for it as well. So no mistake there.
What could be wrong?
Please help. Thanks.
Sounds like the class of the destination view controller is UITabBarController and not your own class RecipeTabBarController. Look in your storyboard as to how you have the segue set up and figure out why things are not what you expect.
I'm using Action Sheet Picket. I added .h and .m files as instructed in readme, picker and even cancelAction is working well but somehow successAction throws NSInvalidArgumentException with this message: "unrecognized selector sent to instance".
Application is a kind of tab bar application with Navigation Controller. There is a TabBarController as root and there are ViewControllers which are located under the TabBarController and one of the ViewControllers is a Navigation Controller. But I'm not getting this error in Navigation Controller. I'm not sure if this causes any error.
Here how I used:
- (IBAction)filterResult:(id)sender {
[ActionSheetStringPicker showPickerWithTitle:#"Pick Filter" rows:self.filterList initialSelection: self.selectedIndexes target:self successAction:#selector(animalWasSelected:element:) cancelAction:nil origin: self];
}
- (void)animalWasSelected:(NSNumber *)selectedIndex element:(id)element {
self.selectedIndexes = [selectedIndex intValue];
NSLog(#"Selected");
}
Yes that's all. I've already included ActionSheetPicker.h file and as I said picker is working fine.
Finally here is error:
[MYYViewController successAction:]: unrecognized selector sent to instance 0x9032400
2012-12-24 12:14:45.488 Example[54268:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MYYViewController successAction:]: unrecognized selector sent to instance 0x9032400'
Any help would be great.
Looks rather straight forward, you need to implement successAction: in your MYYViewController class, because the picker is not checking if it will respond or not and calling it directly.
I have a subview, called DataViewController, and a parent viewcontroller, called RootViewController.
Everytime is try to call a function or set a property that is defined in my RootViewController, from my subview, I get these errors:
Error:
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIPageViewController
setDetailsDataObject:]: unrecognized selector sent to instance
0x6aa2df0'
Code:
RootViewController.h:
#property (strong, nonatomic) id detailsDataObject;
DataViewController.m:
((RootViewController *)self.parentViewController).detailsDataObject = self.dataObject;
And...
Error:
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIPageViewController
showDetails]: unrecognized selector sent to instance 0x6880db0'
Code:
RootViewController.h:
- (void)showDetails;
RootViewController.m:
- (void)showDetails
{
NSLog(#"Hello");
}
DataViewController.m:
[((RootViewController *)self.parentViewController) showDetails];
Does anyone know how to fix these exceptions?
do an Nsaasert statement to check if the self.parentViewController is actually RootViewController instance
NSAssert([self.parentViewController isKindOfClass:[RootViewController class]], #"Not RootViewController");
Try this..correct if there are any spelling mistakes.