Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SunnyLi

Guest
Original poster
Oct 7, 2010
22
0
Hi Guys,

Back again as you were really helpful last time :)

Im following a tutorial on creating a whiteboard drawing app, but everytime i insert a certain piece of code it crashes the app when i go to the settings button.

This is the code:
.h

Code:
//
//  FlipsideViewController.h
//  SampleBrushes
//
//  Created by Andrea Busi on 01/03/10.
//  Copyright BubiDevs 2010. All rights reserved.
//

@protocol FlipsideViewControllerDelegate;


@interface FlipsideViewController : UIViewController {
	id <FlipsideViewControllerDelegate> delegate;
	
	IBOutlet UISlider *sliderRed, *sliderBlue, *sliderGreen, *sliderBlack, *sliderDimension;
	IBOutlet UIImageView *viewColour;
	IBOutlet UILabel *labelDimension;
	
	UIColor *penColour;
	float penDimension;
}

@property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate;
@property (nonatomic, assign) UIColor *penColour;
@property (nonatomic, assign) float penDimension;

- (IBAction)done;
- (IBAction)changeColour;
- (IBAction)changeDimension;

@end


@protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller newColour:(UIColor*)colore newDimension:(float)dimension;
@end

flipsideviewcontroller.m

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
	
	const CGFloat *components = CGColorGetComponents([colorePennello CGColor]);
	[sliderRed setValue:components[0]];
	[sliderGreen setValue:components[1]];
	[sliderBlue setValue:components[2]];
	[sliderBlack setValue:components[3]];
	[viewColore setBackgroundColor:colorePennello];
	labelDimensione.text = [NSString stringWithFormat:@"%f",dimensionePennello];
	[sliderDimensione setValue:dimensionePennello];
}

The tutorial is here:

 
but everytime i insert a certain piece of code it crashes the app when i go to the settings button.
When you insert which certain piece of code? All of what you posted? When the app crashes do you see any error messages in the console? Have you checked the crash log?
 
How come the top code is in English and the bottom code is in Italian?

Anyway, your penColor property should be retain, not assign. This would likely cause a crash.
 
How come the top code is in English and the bottom code is in Italian?

Anyway, your penColor property should be retain, not assign. This would likely cause a crash.

The tutorials in Italian im just puting it into english.

I put breakpoint in just it stops here:

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
	
	const CGFloat *components = CGColorGetComponents([penColour CGColor]);
	[B][sliderRed setValue:components[0]];[/B]
	[sliderGreen setValue:components[1]];
	[sliderBlue setValue:components[2]];
	[sliderBlack setValue:components[3]];
	[viewColour setBackgroundColor:penColour];
	labelDimensions.text = [NSString stringWithFormat:@"%f",penDimension];
	[sliderDimension setValue:penDimension];

	
}

not sure how to get up the crash logs etc
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.