3

I'm an experienced developer, but new to iOS/Objective C.

The app below builds OK (modulo any typo/cut'n'paste errors). When I run it, it breaks in the print method, in a way that makes it look like there is some error. I cannot see what or where the error is. Probably a real newby error though!

Can anyone help me out by explaining what I am doing wrong and how to fix it?

This is a command line MacOS app, with Foundation, being built & run in XCode.

@interface DayOfYear : NSObject
- (void) print;
- (id) init : (int) day;
@end // DayOfYear

@implementation DayOfYear

int dayInYr =0;

- (id) init : (int) day {
    self = [super init];
    dayInYr = day;
    return self;
}

- (void) print {
     // NSLog(@"In print with %d", dayInYr);

}    // WHEN RUN THIS IS WHERE IT BREAKPOINTS SAYING "Thread 1, breakpoint 1.1, 2.1


@end

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        // insert code here...
        NSLog(@"Hello, World!");

        DayOfYear *d =[[DayOfYear alloc] init : 2 ];
        [d print];


        NSLog(@"Finished!");

    }
    return 0;
}
2
  • 1
    Did you accidentally set a breakpoint there? To the left of your code where the breakpoint occurs, check to see if there's a horizontal blue arrow that points to that line of code. Commented Feb 11, 2013 at 21:58
  • make day in year a member of the class. eg DayOfYear : NSObject { int dayInYr; }
    – Bergasms
    Commented Feb 11, 2013 at 22:02

1 Answer 1

17

You have two breakpoints set on the print method. Breakpoints are shown in the left margin as blue flags. You can get rid of them by dragging them out of the margin, like this:

dragging breakpoints out to remove them

2
  • Yep, that was totally it! Thank you, thank you, thank you! It turns out that if you happen to click (not even double click) the mouse while the cursor is in that margin, it sets a breakpoint. I was setting them through ignorance of that feature, and lazy mousing. Much appreciated! Now I can get on with the homework assignment.
    – Peter vdL
    Commented Feb 11, 2013 at 22:49
  • 1
    Just getting started with XCode, this saved me after hours of messing around. Heroic. Commented Jan 7, 2015 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.