unrecognized selector sent to instance in viewcontroller - ios

hi friends i ma using two view controllers in first view controller i am accessing the appdelegate property and try to seeting it but its througing an exception
in appdelegate
#property(nonatomic,assign)NSString *userdate;
in firstview controller
AppDelegate *obj=(AppDelegate *)[[UIApplication sharedApplication]delegate];
obj.userdate=#"abcsde";
its througing an exception here
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate setUserdate:]: unrecognized selector sent to instance 0x717bae0'

Related

Unrecognized selector error when pushing segue in Objective C

I have an app which has a sidebar menu (a UITableView) with different rows that are connected separately with the main view controller with a (push) Segue.
Only one of this doesn't work, so when I tap on it I recieve this message:
**** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainTabBarController topViewController]: unrecognized selector sent to instance 0x14880ce00'terminating with uncaught exception of type NSException*
In the SideBarViewController this is the part of the code that causes the crash:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(#"[segue identifier]: %#",[segue identifier]);
if ([[segue identifier] isEqualToString:#"sync"]) {
MainViewController *mainViewSync= (MainViewController *)[[segue destinationViewController] topViewController];
mainViewSync.sync = 1;
}}
How can I fix That?

"Terminating app due to uncaught exception" getting crash when pushing view controller

Terminating app due to uncaught exception 'NSInvalidArgumentException', > reason: '-[UIViewController setDicSelectListItem:]: unrecognized selector sent to instance 0x10981be30'
I tried comment parameter passing. also tried provide main storyboard.
Below is the code where app getting crash
BilingInfoVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"BilingInfoVC"];
vc.dicSelectListItem=_dicSelectListItem;
vc.serviceType=_serviceType;
vc.arrSelect_Addons = [arrTemp mutableCopy];
[self.navigationController pushViewController:vc animated:YES];
I want to pass parameters with instantiate view controller.
Check this:
Is vc really of class 'BilingInfoVC'? If you didn't assign it correctly in IB it's a standard view controller.
You may check it with
NSLog(#"Class: %#", [vc className]);
As second line right after instantination of vc.
Did you set the identifier correctly? A capital letter can make a difference!

Can't set data to an array in prepareForSegue

I'm using Objective-C, I want to copy an array for another view controller and push it. Here is my code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"comment"]){
commentViewController *vc = segue.destinationViewController;
vc.comments = [[NSArray alloc]initWithArray:comments];
}
}
But it doesn't work. I got this in Xcode:
2015-12-06 16:27:45.802 net[1244:29117] -[UIViewController setComments:]: unrecognized selector sent to instance 0x7ff8d34eb720
2015-12-06 16:27:45.807 net[1244:29117] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setComments:]: unrecognized selector sent to instance 0x7ff8d34eb720'
Someone can help me?
Select your destination view controller in the storyboard. And in the identity inspector make sure that your destination vc is your custom class as seen in the pic.

Add Value to property on ViewController from AppDelegate

I have the following code:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
[tabBarController performSegueWithIdentifier:#"push_display_incomming_call" sender:self];
This shows me the ViewController I want to see correctly. But now I want to change the property's value of the ViewController is being Segue before it's shown, I'm Trying the following with no success.
incommingCallViewController *mainController = (incommingCallViewController*) tabBarController;
mainController.name.text = #"Eddwn Paz";
This is the stacktrace from xCode Console:
2014-07-10 16:46:09.413 mobile-app[9354:60b] -[OptionsTabBarViewController name]: unrecognized selector sent to instance 0x17552540
2014-07-10 16:46:09.414 mobile-app[9354:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OptionsTabBarViewController name]: unrecognized selector sent to instance 0x17552540'
Assume that push_display_incomming_call segue presents IncommingCallViewController view controller as modal. So you should use code:
IncommingCallViewController *callVC =
(IncommingCallViewController *)tabBarController.presentedViewController;
callVC.name.text = #"Eddwn Paz";
Remarks:
You receive the error because you try to use tabBarController as instance of incommingCallViewController while it is instance of UITabBarController thus it does not have required name property.

Adding TabBarController to splitViewController

I have removed the "detail" navigationController from the "master-detail" template to reconnect it correctly to a tabBarController and move the "detail" viewController to the first tab.
Then I got this error:
2014-01-07 21:11:20.364 master-detail[3033:70b] -[UITabBarController topViewController]: unrecognized selector sent to instance 0x9e46e70
2014-01-07 21:11:20.366 master-detail[3033:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController topViewController]: unrecognized selector sent to instance 0x9e46e70'
So I replace this line in function "application - didFinishLaunchingWithOptions":
...
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
For:
UITabBarController *tabBarController = [splitViewController.viewControllers lastObject];
UINavigationController *navigationController = tabBarController.viewControllers[0];
But still:
2014-01-07 20:59:38.377 EngLogBook[2955:70b] -[elbDetailViewController topViewController]: unrecognized selector sent to instance 0x8d86ff0
2014-01-07 20:59:38.380 EngLogBook[2955:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[elbDetailViewController topViewController]: unrecognized selector sent to instance 0x8d86ff0'
What's wrong?
For both iPad and iPhone storyboard. iPhone work just great but iPad is messy.
What you're describing does not sound like it will work with standard UIKit tools. You may want to re-think how you're building and laying out your interface. Apple has documents that should provide some guidance.
Apple Human Interface Guidelines - Navigation

Resources