Created a Next button for iOS app… giving SIGABRT error upon clicking












0















I'm trying to build a GoogleMaps based application. When the user is on MapViewController, I want them to be able to choose a location on the map and click Next at the Top right. Doing so should take them to another screen with a description of the location (HomeViewController). I'm stuck on implementing the Next button. My current code for the button looks like this...



override func viewDidLoad()
{
....

navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(MapViewController.next as (MapViewController) -> () -> ()))

}

func next()
{
print("next")
if let navController = self.navigationController, let viewController = self.storyboard?.instantiateViewController(withIdentifier: "indentfier") as? HomeViewController{
navController.pushViewController(viewController, animated: true)
}
}


I ran it at first with just the print("next") and it worked (i.e., it just printed "next" to the console). When I added the second line with the push, the app started to crash when I clicked Next. I also got a SIGABRT error on my app delegate.



Note: HomeViewController is actually the home page; it's a previous screen that the user will have already seen a 4-5 screens before the map. I basically want them to go back a few screens to the home page when they hit Next.



Any help would be appreciated. Thank you.










share|improve this question

























  • You need to tag your next function with @objc. Also #selector(MapViewController.next as (MapViewController) -> () -> ()) this could just be #selector(next)

    – Oscar Apeland
    Nov 20 '18 at 18:56


















0















I'm trying to build a GoogleMaps based application. When the user is on MapViewController, I want them to be able to choose a location on the map and click Next at the Top right. Doing so should take them to another screen with a description of the location (HomeViewController). I'm stuck on implementing the Next button. My current code for the button looks like this...



override func viewDidLoad()
{
....

navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(MapViewController.next as (MapViewController) -> () -> ()))

}

func next()
{
print("next")
if let navController = self.navigationController, let viewController = self.storyboard?.instantiateViewController(withIdentifier: "indentfier") as? HomeViewController{
navController.pushViewController(viewController, animated: true)
}
}


I ran it at first with just the print("next") and it worked (i.e., it just printed "next" to the console). When I added the second line with the push, the app started to crash when I clicked Next. I also got a SIGABRT error on my app delegate.



Note: HomeViewController is actually the home page; it's a previous screen that the user will have already seen a 4-5 screens before the map. I basically want them to go back a few screens to the home page when they hit Next.



Any help would be appreciated. Thank you.










share|improve this question

























  • You need to tag your next function with @objc. Also #selector(MapViewController.next as (MapViewController) -> () -> ()) this could just be #selector(next)

    – Oscar Apeland
    Nov 20 '18 at 18:56
















0












0








0








I'm trying to build a GoogleMaps based application. When the user is on MapViewController, I want them to be able to choose a location on the map and click Next at the Top right. Doing so should take them to another screen with a description of the location (HomeViewController). I'm stuck on implementing the Next button. My current code for the button looks like this...



override func viewDidLoad()
{
....

navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(MapViewController.next as (MapViewController) -> () -> ()))

}

func next()
{
print("next")
if let navController = self.navigationController, let viewController = self.storyboard?.instantiateViewController(withIdentifier: "indentfier") as? HomeViewController{
navController.pushViewController(viewController, animated: true)
}
}


I ran it at first with just the print("next") and it worked (i.e., it just printed "next" to the console). When I added the second line with the push, the app started to crash when I clicked Next. I also got a SIGABRT error on my app delegate.



Note: HomeViewController is actually the home page; it's a previous screen that the user will have already seen a 4-5 screens before the map. I basically want them to go back a few screens to the home page when they hit Next.



Any help would be appreciated. Thank you.










share|improve this question
















I'm trying to build a GoogleMaps based application. When the user is on MapViewController, I want them to be able to choose a location on the map and click Next at the Top right. Doing so should take them to another screen with a description of the location (HomeViewController). I'm stuck on implementing the Next button. My current code for the button looks like this...



override func viewDidLoad()
{
....

navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(MapViewController.next as (MapViewController) -> () -> ()))

}

func next()
{
print("next")
if let navController = self.navigationController, let viewController = self.storyboard?.instantiateViewController(withIdentifier: "indentfier") as? HomeViewController{
navController.pushViewController(viewController, animated: true)
}
}


I ran it at first with just the print("next") and it worked (i.e., it just printed "next" to the console). When I added the second line with the push, the app started to crash when I clicked Next. I also got a SIGABRT error on my app delegate.



Note: HomeViewController is actually the home page; it's a previous screen that the user will have already seen a 4-5 screens before the map. I basically want them to go back a few screens to the home page when they hit Next.



Any help would be appreciated. Thank you.







ios swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 21:52









Sh_Khan

42k51326




42k51326










asked Nov 20 '18 at 18:53









srsrsosrsrso

344




344













  • You need to tag your next function with @objc. Also #selector(MapViewController.next as (MapViewController) -> () -> ()) this could just be #selector(next)

    – Oscar Apeland
    Nov 20 '18 at 18:56





















  • You need to tag your next function with @objc. Also #selector(MapViewController.next as (MapViewController) -> () -> ()) this could just be #selector(next)

    – Oscar Apeland
    Nov 20 '18 at 18:56



















You need to tag your next function with @objc. Also #selector(MapViewController.next as (MapViewController) -> () -> ()) this could just be #selector(next)

– Oscar Apeland
Nov 20 '18 at 18:56







You need to tag your next function with @objc. Also #selector(MapViewController.next as (MapViewController) -> () -> ()) this could just be #selector(next)

– Oscar Apeland
Nov 20 '18 at 18:56














1 Answer
1






active

oldest

votes


















1














Replace



navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))




@objc func next(_ bar:UIBarButtonItem) {

}





share|improve this answer
























  • Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

    – srsrso
    Nov 20 '18 at 19:03






  • 1





    may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

    – Sh_Khan
    Nov 20 '18 at 19:05






  • 1





    Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

    – srsrso
    Nov 20 '18 at 20:37













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399692%2fcreated-a-next-button-for-ios-app-giving-sigabrt-error-upon-clicking%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Replace



navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))




@objc func next(_ bar:UIBarButtonItem) {

}





share|improve this answer
























  • Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

    – srsrso
    Nov 20 '18 at 19:03






  • 1





    may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

    – Sh_Khan
    Nov 20 '18 at 19:05






  • 1





    Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

    – srsrso
    Nov 20 '18 at 20:37


















1














Replace



navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))




@objc func next(_ bar:UIBarButtonItem) {

}





share|improve this answer
























  • Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

    – srsrso
    Nov 20 '18 at 19:03






  • 1





    may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

    – Sh_Khan
    Nov 20 '18 at 19:05






  • 1





    Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

    – srsrso
    Nov 20 '18 at 20:37
















1












1








1







Replace



navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))




@objc func next(_ bar:UIBarButtonItem) {

}





share|improve this answer













Replace



navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))




@objc func next(_ bar:UIBarButtonItem) {

}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 18:57









Sh_KhanSh_Khan

42k51326




42k51326













  • Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

    – srsrso
    Nov 20 '18 at 19:03






  • 1





    may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

    – Sh_Khan
    Nov 20 '18 at 19:05






  • 1





    Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

    – srsrso
    Nov 20 '18 at 20:37





















  • Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

    – srsrso
    Nov 20 '18 at 19:03






  • 1





    may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

    – Sh_Khan
    Nov 20 '18 at 19:05






  • 1





    Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

    – srsrso
    Nov 20 '18 at 20:37



















Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

– srsrso
Nov 20 '18 at 19:03





Thank you for the help... App delegate is still giving me a SIGABRT error, however. I changed my code as per your suggestion. Any thoughts? Thanks again!

– srsrso
Nov 20 '18 at 19:03




1




1





may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

– Sh_Khan
Nov 20 '18 at 19:05





may be there is a problem in your next vc HomeViewController create an empty controller and navigate to it to verify this also check if the next function is called or not , track your code with logs*breakpoints

– Sh_Khan
Nov 20 '18 at 19:05




1




1





Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

– srsrso
Nov 20 '18 at 20:37







Thanks Sh_Khan, I just needed to manually add a Segue from my MapVC to HomeVC.

– srsrso
Nov 20 '18 at 20:37




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399692%2fcreated-a-next-button-for-ios-app-giving-sigabrt-error-upon-clicking%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$