1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

iPhone app crashes on startup

Discussion in 'iPhone/iPad Programming' started by Ricky429, Jan 9, 2011.

  1. macrumors newbie

    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?
  2. Moderator


    Staff Member

    Please be specific. Which book and which practice app?

    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.
  3. macrumors newbie

    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.
  4. Moderator


    Staff Member

    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.

    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. 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. :)
  5. macrumors newbie

    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];
    				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];
    		toggle = YES;
    after debugging it the line of code that has the problem is the: [billField becomesFirstResponder]; line.

Share This Page