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.

iOS Build a Simple iPhone App (iOS7) Refactoring into a Model Readonly Attribute

Joannie Huang
Joannie Huang
6,195 Points

When I execute the code, it will have a thread regarding the memory thrown.

I have double-check the code, its without any syntax error and is same as video. And when execute the code, it will have a on the ViewDidLoad function.

#import "THViewController.h"
#import "THCrystallBall.h"

@interface THViewController ()

@end

@implementation THViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.crstalBall = [[THCrystallBall alloc] init];

    // 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 {

    self.predictionLabel.text = [self.crstalBall randomPrediction];

}


@end

4 Answers

Does your project come up with a green line anywhere saying "Thread 1:Breakpoint 1.1"? If so you will need to use the keyboard shortcut CMD(?)+7 to bring up all these breakpoints. Take note of the code that has been selected as a breakpoint (possibly write it down first) and then delete the highlighted code. Then re-input the code that has been deleted (do not copy and paste) Save your code and test it. Hopefully this should work.

I know you said it is not a syntax error but I would just like to check, did you spell "crstalBall" like that in your code on purpose instead of "crystalBall" and "THCrystallBall" instead of "THCrystalBall"?

Joannie Huang
Joannie Huang
6,195 Points

Hi Joshua, yes, I was define the cystalBall and THCrystallBall in my code. I think the compiler has passed the code, but when execute it, then would show the exception on the viewDidLoad function. Not sure it's regarding the memory allocate issue?

Joannie Huang
Joannie Huang
6,195 Points

Hi Joshua, Thanks a lot. I followed your steps and it works now! Just curious that the breakpoint was occurring on the "}" and the comment which is from the project sample file.... Why is the cause reason of this, do you know?

You're welcome, I'm glad it worked for you. Sorry I don't have a clue why this happened.