Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


James Kenny
James Kenny
2,968 Points

Self Destructing Message iPhone App: Creating method for IBAction

I have been doing ok with the Challenges until now but this one has stopped me dead. I cant see where in the material we have covered this particular subject. And after looking at ios docs and various forums , anything I try is not accepted. The question is:

"In the view controller below about songs, tapping on a button to add a new song needs to perform a segue to another view controller. The button is wired up to an IBAction with the signature '- (void)addSong'. Start by defining this method."

And the provided code starting point is :

import "MusicViewController.h"

@implementation MusicViewController

  • (void)viewDidLoad { [super viewDidLoad]; }


What kind of error message are you getting?

3 Answers

OK - so you want to create an instance method that is an IBAction. Given that there are no instructions on what should be in a method, we'll assume that it needs to be blank - so it should be in the form:

  • (returnType)methodName {}

However, this isn't quite correct as it is specified that this reflects an IBAction. IBAction (and IBOutlet) are sort of hints that indicate that there should be info in the nib or Storyboard related to this method - ie the link to the button etc..

The format for defining methods that are IBActions is as follows:

  • (IBAction)methodName {}

Does this help?

James Kenny
James Kenny
2,968 Points

Thanks for the help. I sorted it now. Clumsy fingers causing syntax errors I think was my problem.


James Kenny
James Kenny
2,968 Points

THanks for responding back to me Eirik. I sorted it out. It was a simple syntax problem I guess cos when I tried again I must have done something different and the code challange parser decided it was ok.