Created a Next button for iOS app… giving SIGABRT error upon clicking
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
add a comment |
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
You need to tag yournext
function with@objc
. Also#selector(MapViewController.next as (MapViewController) -> () -> ())
this could just be#selector(next)
– Oscar Apeland
Nov 20 '18 at 18:56
add a comment |
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
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
ios swift
edited Nov 20 '18 at 21:52
Sh_Khan
43.6k51329
43.6k51329
asked Nov 20 '18 at 18:53
srsrsosrsrso
344
344
You need to tag yournext
function with@objc
. Also#selector(MapViewController.next as (MapViewController) -> () -> ())
this could just be#selector(next)
– Oscar Apeland
Nov 20 '18 at 18:56
add a comment |
You need to tag yournext
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
add a comment |
1 Answer
1
active
oldest
votes
Replace
navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))
@objc func next(_ bar:UIBarButtonItem) {
}
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Replace
navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))
@objc func next(_ bar:UIBarButtonItem) {
}
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
add a comment |
Replace
navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))
@objc func next(_ bar:UIBarButtonItem) {
}
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
add a comment |
Replace
navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))
@objc func next(_ bar:UIBarButtonItem) {
}
Replace
navigationItem.rightBarButtonItem = UIBarButtonItem(title:"Next", style: .plain, target: self, action: #selector(self.next(_:)))
@objc func next(_ bar:UIBarButtonItem) {
}
answered Nov 20 '18 at 18:57
Sh_KhanSh_Khan
43.6k51329
43.6k51329
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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