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

iOS crystal ball app help

I am up to the stage where you add the background.png into the code files and when I try to run it the program doesn't give me an error but a green line going through the code that contains @"background.png". Does anyone know what to do to fix this?

7 Answers

Hey Zac,

We'll get you an answer on this as soon as we can! Thanks for being a Treehouse Member :)

Ryan

Founder/CEO, Treehouse

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

@zac It might be that there is a spelling mistake in the actual name of the file or in your code. If you want I can take look. Could you post your code? You can zip it up and put on Dropbox and share it.

Absolutely, here is my code:

-This is my ViewController.m:

 //
//  ViewController.m
//  CrystalBall
//
//  Created by zac plett on 2/18/13.
//  Copyright (c) 2013 zac plett. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize predictionLabel;
@synthesize predictionArray;

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImage *image = [UIImage imageNamed:@"background.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    [self.view addSubview:imageView];
     self.predictionArray = [[NSArray alloc] initWithObjects:@"It is certain",@"It is possible",@"I would say YES",

                                @"The stars are not aligned",
                                @"My reply is no",
                                @"It is doubtful",
                                @"Better not to tell you now",
                                @"Concentrate and ask again",
                                @"Unable to answer now", nil];


    // 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:(UIButton *)sender {
    NSUInteger index = arc4random_uniform(self.predictionArray.count);
    self.predictionLabel.text = [self.predictionArray objectAtIndex:index];
}
@end

-And this is my ViewController.h:

//
//  ViewController.h
//  CrystalBall
//
//  Created by zac plett on 2/18/13.
//  Copyright (c) 2013 zac plett. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController :
    UIViewController {
}


@property (strong, nonatomic) IBOutlet UILabel *predictionLabel;
@property (strong, nonatomic)NSArray *predictionArray;

- (IBAction)buttonPressed:(UIButton *)sender;


@end

And I got dropbox and I hope this link works: https://www.dropbox.com/sh/j5u7bjls7dl1tb2/dGdx9Py2mU

when I run it I get redirected back to ViewController.m, it highlights this line of code in green: UIImage *image = [UIImage imageNamed:@"background.png"]; and says this message: Thread 1: breakpoint 3.1

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

@zac seems like you have a breakpoint in there. Do you see a blue arrow to the left of the line? If so, then you can simply click on the arrow to disable it or right-click on it and select delete breakpoint.

ok awesome thank you so much Amit! I will continue the video and finish my app :)

Ok well I got through everything and now when I try to install it on my phone I get this error message:

Check dependencies

Code Sign error: The identity 'iPhone Developer' doesn't match any valid, non-expired certificate/private key pair in your keychains