Reload Data throwing unrecognized selector sent to instance - objective-c

I seem to be experiencing a small error when dismissing a view and navigating back to a ViewController (with a UITableView)
This is the code that loads the data into the tableView
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[getData getSavedTanks:^(NSArray *results) {
self.array = results;
[self.tankList reloadData];
NSLog(#"%#", results);
}];
}
The followup view in the stack is properly called, but when the view is dismissed, it seems as though the tableView has trouble reloading the data, and is throwing this error:
2014-04-28 21:15:57.698 ReefTrack[10205:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFObject reloadData]: unrecognized selector sent to instance 0x10be93210'
Not really sure how to handle this. I'm having trouble understanding why reloadData is throwing an error. I checked to see if there are any errant Segues pointing towards reload data but there doesn't appear to be. Anyone have any thoughts on this?

UPDATE:
This was solved by placing the entire function in viewDidLoad.

Related

Exception :unrecognized selector sent to instance Dismissing View Controller in IOS 8

I have open another view successfully in current view using the following code
OptionsViewController *optionView = [[OptionsViewController alloc] initWithNibName:IS_IPAD()?#"OptionsViewController_ipad":#"OptionsViewController" bundle:nil];
[self.navigationController presentViewController:optionView animated:YES completion:Nil];
They i'm trying to dismiss current view in OptionsViewController using the following code. But im getting "unrecognized selector sent to instance" and app crashes in IOS 8 but lower version it was working fine . Please help me how to resolve .
Please check below link for exception message http://pastebin.com/R4M3MxmM
- (IBAction)cancelOption:(id)sender
{
[self dismissViewControllerAnimated:YES completion:Nil];
}
The trace says your problem is in [LeftSideBarViewController tableView:numberOfRowsInSection:]. Apparently, you're asking for the count of something but that thing is currently a UITraitCollection which, I'm guessing, is not what you expect.
The most likely explanation is that the thing you're trying to count has been released and its memory reused.
If it's not obvious from that, run Instruments with zombies enabled and look at the retain/release history of the object involved. (Or post the code from the crashing method.)
:count on the object doesn't exist.
https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITraitSet_ClassReference/index.html
UITraitCollection has no instance method called count.

ECSlidingViewController not First View

My application start with a view thats not use ECSlidingViewController, and then have a button to another that uses it.
In switching the views using Storyboard Segue, but I'm getting error.
What should I add to btnGoSecondView to load ECSlidingViewController properly?
Code:
-(IBAction)btnGoSecondView:(id)sender {
[self performSegueWithIdentifier:#"SecondViewShow" sender:self];
}
Error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
i think you should make some initialview first, and make that view became initial view controller and make an identifier for every each view controller.
something like this ..
self.viewcontroller = [storyboard instantiateViewControllerWithIdentifier:#"home"];
Based on the error you're getting an object is trying to be inserted into a mutable array but it hasn't been initialised. Where is the exception thrown in your code?
Try work out where the array is being accessed and why it's null. The NSMutableArray may not have been initialised in which case you'll need to initialise it.
NSMutableArray *arrayName = [NSMutableArray new];
Another thought: Before the ECSlidingViewController is presented I think you need to set it's topViewController. You could add it in -prepareForSegue:sender: or in the viewDidLoad of the viewController to be presented.
Something like this perhaps:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
ECSlidingViewController *slidingViewController = (ECSlidingViewController *)segue.destinationViewController;
slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"FirstTop"];
}

Can I have a block of code run only if user is on iPhone vs iPad?

I have a master-detail app that is working great for the iPad. However, the iPhone version doesn't work because a variable that is being sent to the DetailViewController in the iPad version doesn't send to the iPhone DetailViewController. I can fix this with a single line of code in MasterViewController implementation:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
self.detailViewController=segue.destinationViewController;
}
Unfortunately, when I implement that code, the iPad version stops working. I get an exception when I go from another view controller (HomeViewController) back to DetailViewController. That error log is:
2012-07-14 14:29:12.924 46 Tracker[2772:11603] -[HomeViewController setDetailItem:]: unrecognized selector sent to instance 0x7cad4f0
2012-07-14 14:29:12.925 46 Tracker[2772:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HomeViewController setDetailItem:]: unrecognized selector sent to instance 0x7cad4f0'
*** First throw call stack:
(0x148a022 0x201acd6 0x148bcbd 0x13f0ed0 0x13f0cb2 0x2cb0 0x2d75c5 0x2d77fa 0xb6c85d 0x145e936 0x145e3d7 0x13c1790 0x13c0d84 0x13c0c9b 0x16a07d8 0x16a088a 0x246626 0x1fdd 0x1f45)
terminate called throwing an exception(lldb)
So, is there any way I can run that first block of code only when the user is on the iPhone? Or, can I fix the code to make it work properly on both devices?
Here is a link to my iPad storyboard to (hopefully) make it more clear. I have a problem when I click on a table cell AFTER going from HomeViewController back to DetailViewController: http://www.grapekeeper.com/storyboards.png
Perhaps the following?
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// perform iPad logic
} else {
// perform iPhone logic
}

NSInvalidArgumentException for implementing UIWebView

I am writing an app for iPad. I have several views. On navigation bar I have 2 buttons for shopping cart and youtube. pressing them takes to the browser in the app itself. I have made another class for browser and added an outlet for UIWebView. In browser class viewDidLoad method I wrote the following lines.
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.hidesBackButton = YES;
self.title = #"Browser";
[webView loadRequest:[NSURL URLWithString:#"http://cfsmail.com"]];
}
The build is successful and app runs. But when I press any of those buttons it terminates with following error.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL URL]: unrecognized selector sent to instance 0x4b39600'
Please guide
Regards
Prateek
What you are doing wrong is that loadRequest requires a NSURLRequest, not NSURL. Try:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://cfsmail.com"]]];

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController modalTransitionStyle]:

i used the following code to display my image picker controll.
IPopoverController *popoverController = [[[UIPopoverController alloc] initWithContentViewController:myImagePicker] retain];
[self presentModalViewController:popoverController animated:YES];
but there is a error that shows
working with image view[14335:207] *
Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'-[UIPopoverController
modalTransitionStyle]: unrecognized
selector sent to instance 0x6415950'.
can any one help me please.
You need to use this...
[popoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Or one of the other present methods, check the Apple docs.
The short answer is that you cannot use UIPopoverController to present it as a modal one. Please try using UIViewController instead.
You probably will need to subclass it and either load it from some nib or create its view content manually in loadView method.