Thread 1: signal SIGABRT --builds successful but app crashes in simulator


Thread 1: signal SIGABRT --builds successful but app crashes in simulator



I got this error after putting in this section of code to an app I'm making


PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];



Whenever I hit run, it says "Build Successful" but the app the crashes in the simulator. Can someone help me figure out what's wrong?





If it crashes, there is an error message in console? Could you give it?
– Larme
Jul 2 at 14:20





FYI - a successful build does not mean your app doesn't have bugs that can lead to a crash at runtime.
– rmaddy
Jul 2 at 16:01





You need to point out the exact line of code causing the crash and you need to update your question with the complete error message.
– rmaddy
Jul 2 at 16:02





I can't find any reference to viewControllerAtIndex: in the developer docs. Is this a custom method you've written? If so, you need to provide it, because, if I had to guess, your app is crashing because you're trying to access an array index that doesn't actually exist.
– Nima Yousefi
Jul 2 at 16:46


viewControllerAtIndex:




1 Answer
1



The only thing may be wrong here is that [self viewControllerAtIndex:0]; returns NULL. You cannot create NSArray with NULL element.


[self viewControllerAtIndex:0];






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages