Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

James Hadjisavas
12,365 PointsCode Challenge: Adding Login and Sign Up Screens
Hi, I could really use some help with this one.
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.
#import "MusicViewController.h"
@implementation MusicViewController
- (void)viewDidLoad {
[super viewDidLoad];
- (IBAction)addSong:(id)sender {
}
}
@end
That's all I got.
1 Answer

Amit Bijlani
Treehouse Guest TeacherThe method signature is provided in the question. So you should define it exactly as mentioned: - (void)addSong
.
James Hadjisavas
12,365 PointsJames Hadjisavas
12,365 PointsHi Amit,
Thanks for replying. I'm still having difficultly with this one.
import "MusicViewController.h"
@implementation MusicViewController Hey Amit, thanks for the reply. I'm still struggling with this. I know I need to tell it to perform a segue right?
(void)viewDidLoad { [super viewDidLoad];
(void)addSong:(id)sender { } }
@end
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherYou cannot define one method inside another. The
addSong
is a separate method definition which means it's outside the curly braces of theviewDidLoad
method. Also the method definition does not take an argumentsender. It is simply
-(void)addSong`.