Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:23:31+00:00 2026-05-28T00:23:31+00:00

So I’ve been holding off asking this question for a while because I know

  • 0

So I’ve been holding off asking this question for a while because I know the solution will most likely be something very very simple. But I have come to the end of my tether so here goes:

I have created a UIButton programatically and linked it to a method, but it is not working!!

.h definition

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface CreaterPage : UIViewController
{
IBOutlet UIView *postcardView;
IBOutlet UIButton *returnButton;
}

-(void)goBack:(UIButton *)button;

@end

.m definition

#import "CreaterPage.h"

@implementation CreaterPage

-(void)viewDidLoad
{
NSLog(@"Creater Page View Loaded Successfully");
UIButton *goHomeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[goHomeButton addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchDown];
[goHomeButton setTitle:@"Go Back" forState:UIControlStateNormal];
goHomeButton.frame = CGRectMake(100, 100, 100, 100);
[self.view addSubview:goHomeButton];
}

-(void)goBack:(UIButton *)button
{
NSLog(@"Home");
}

@end

And basically, when I run the code, the button appears as defined but my program crashes whenever I press it.

In the main.m file, it gives me the error

Thread 1: Program received signal: “EXC_BAD_ACCESS”.

On the line

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

I’ve tried all sorts and only turned to creating it programatically because I couldn’t get it working through the interface builder.

So I’m hoping somebody on here can change my juvenile ways and show me where I’m going wrong 😀

Thanks,

Matt

EDIT 1: Changed @selector(goBack) to @selector(goBack:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:23:32+00:00Added an answer on May 28, 2026 at 12:23 am

    My first guess would be that your action is defined as such:

    [goHomeButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchDown];
    

    Note the @selector(goBack) without a colon following the method name. Your method in your .m file is defined as:

    -(void)goBack:(UIButton *)button
    

    So I imagine changing your action to @selector(goBack:) would clear things up.

    Sidenote: It’s very uncommon to define the type of the sender for an IBAction, as you have done. While you might not encounter any issues as long as your UIButton is the only UI object that causes the method to be called, it’s very poor practice. You should change your method signature to:

    -(IBAction)goBack:(id)sender
    

    Note also the use of IBAction in place of void. While they’re syntatically the same thing, the IBAction makes it clear to readers, and to Interface Builder, which methods are available for linking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need a function that will clean a strings' special characters. I do NOT
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.