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! While you're at it, check out some resources Treehouse students have shared here.

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

iOS Build a Simple iPhone App (iOS7) Getting Started What is an IBAction?

Marilyn Wagner
Marilyn Wagner
6,666 Points

Can't see "Button Pressed" on console

I followed all instructions in video and confirmed that the button was connected to the IBAction (i.e when I hovered, the button became highlighted). Then in my ViewController.m I added the NSLog statement. When I ran the app, the iOS Simulator was totally black and stayed black. Not until I hit "Stop" to stop running the app did I see on the Simulator an icon in the upper left section labeled "CrystalBall" with a Safari icon at bottom. When I clicked on the "CrystalBall" icon I saw the correct page: "It is decidedly so" with the blue "Predict" button. At this point the app had stopped running. Consequently, nothing ever appeared in the console. Any thoughts on what I need to do? Thank you!!!!

can i see your code.

Marilyn Wagner
Marilyn Wagner
6,666 Points

Thank you for your help. Here is my code:

//
//  MWViewController.h
//  CrystalBall
//
//  Created by Marilyn Wagner on 5/2/14.
//  Copyright (c) 2014 MarilynWagner. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MWViewController : UIViewController
- (IBAction)buttonPressed;

@end


//
//  MWViewController.m
//  CrystalBall
//
//  Created by Marilyn Wagner on 5/2/14.
//  Copyright (c) 2014 MarilynWagner. All rights reserved.
//

#import "MWViewController.h"

@interface MWViewController ()

@end

@implementation MWViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)buttonPressed {
    NSLog(@"Button Pressed");
}
@end

2 Answers

Hi Marilyn,

Here's what I have in my 'buttonPressed' method. Hope this helps -

- (IBAction)buttonPressed {

    self.predictionLabel.text = [self.predictions objectAtIndex:3];
    NSLog(@"Button Pressed");

}