PDA

View Full Version : iPhone app crashes on startup




Ricky429
Jan 9, 2011, 10:48 PM
Hello all I'm new to iphone programming and I'm having trouble with an app. Whenever I try and build a practice app from a beginners book that I bought it always crashes with no errors whatsoever. I have already deleted it and built again from scratch with the same problem.

I was wondering what could be the problem and how do I solve it?



dejo
Jan 10, 2011, 09:49 AM
Whenever I try and build a practice app from a beginners book that I bought...
Please be specific. Which book and which practice app?

...it always crashes with no errors whatsoever.
Have you checked the crash log? What other basic debugging have you tried? The more information you can tell us about what you've already done to troubleshoot will help us help you.

Ricky429
Jan 10, 2011, 11:47 AM
The book I'm using is the Deitel Developers Series; IPhone for Programmers An App-Driven Approach. The app I'm trying to make is the tip calculator app within the book.

I have checked everything and it all says the build was successful. And I should also mention that whenever it builds and installs on the simulator the application unexpectedly quits.
I've debugged it and it says that it terminated due to uncaught exception; the GD8 was interrupted.

dejo
Jan 10, 2011, 01:44 PM
The book I'm using is the Deitel Developers Series; IPhone for Programmers An App-Driven Approach. The app I'm trying to make is the tip calculator app within the book.
And you've gone through your code very carefully to make sure it matches what's in the book? Does the book have an errata available? All this is to make sure you're running the same code the author thinks you should be running.

I have checked everything and it all says the build was successful. And I should also mention that whenever it builds and installs on the simulator the application unexpectedly quits.
I've debugged it and it says that it terminated due to uncaught exception; the GD8 was interrupted.
You checked everything? Including the crash log? If so, what did it say? It should tell you on which line of code it's crashing. Maybe have a look at the Xcode Debugging Guide (http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/Conceptual/XcodeDebugging/000-Introduction/Introduction.html). Then post the code for the method (at least) where the crash is occurring. Just to be clear, "debugging it" is not just finding the error that caused the crash; it's also tracking down at what line this error occurs and then determining what is the cause. Hope that helps. :)

Ricky429
Jan 10, 2011, 09:57 PM
I've downloaded there code for the same app and it matches what their code perfectly.


#import "Controller.h"


@implementation Controller

- (void)awakeFromNib
{
[billField becomesFirstResponder];
}

- (IBAction)calculateTip:(id)sender
{
static BOOL toggle = YES;

if (toggle)
{
toggle = NO;
NSString *billFieldText = billField.text;

float newTotal = [billFieldText floatValue];

float customTipPercent = customPercentSlider.value;

if (sender == billField)
{
if (billFieldText.length < billTotal.length)
billTotal = [NSString stringWithFormat:@"%.02f",
newTotal / 10];
else
billTotal = [NSString stringWithFormat:@"%.02f",
newTotal * 10];

billField.text = billTotal;

newTotal = [billTotal floatValue];

float tenTip = newTotal * 0.10;
float fifteenTip = newTotal * 0.15;
float twentyTip = newTotal * 0.20;

tipFieldTen.text = [NSString stringWithFormat:@"%.02f", tenTip];
tipFieldFifteen.text = [NSString stringWithFormat:@"%.02f", fifteenTip];
tipFieldTwenty.text = [NSString stringWithFormat:@"%.02f", twentyTip];

totalFieldTen.text = [NSString stringWithFormat:@"%.02f", newTotal + tenTip];
totalFieldFifteen.text = [NSString stringWithFormat:@"%.02f", newTotal + fifteenTip];
totalFieldTwenty.text = [NSString stringWithFormat:@"%.02f", newTotal + twentyTip];
}
else if (sender == customPercentSlider)
{

int percentage = (int)(customTipPercent * 100);

customPercentLabel.text = [NSString stringWithFormat:@"%i%%", percentage];

float newSliderValue = ((float) percentage) / 100;
customPercentSlider.value = newSliderValue;

customTipPercent = newSliderValue;
}

float customTip = customTipPercent * newTotal;

tipFieldCustom.text = [NSString stringWithFormat:@"%.02f", customTip];

totalFieldCustom.text = [NSString stringWithFormat:@"%.02f", customTip + newTotal];
}
else
{
toggle = YES;
}
}
@end

after debugging it the line of code that has the problem is the: [billField becomesFirstResponder]; line.