Search code examples
objective-cxcode4breakpoints

Breakpoint-only error with managed objects


While trying to debug my program in Xcode 4.2, I turned on breakpoints and discovered a problem in this piece of code located in my AppDelegate.m file.

#pragma mark -
#pragma mark Core Data stack

/**
 Returns the managed object context for the application.
 If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
 */
- (NSManagedObjectContext *)managedObjectContext {

    if (managedObjectContext_ != nil) {
        return managedObjectContext_;
    }

    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
    if (coordinator != nil) {
        managedObjectContext_ = [[NSManagedObjectContext alloc] init];
        [managedObjectContext_ setPersistentStoreCoordinator:coordinator];
    }
    return managedObjectContext_;
}

At

if (managedObjectContext_ != nil) {

Xcode tells me that "Thread 1: Stopped at breakpoint #" and refuses to finish compiling my program. However, if I turn off breakpoints and run my program normally, it works just fine. Does anyone know why this is so? Thanks in advance :)


Solution

  • The breakpoints are doing what they are supposed to do, which is to stop the program so you can examine the variable values and fix bugs. Pressing the button which roughly looks like |> will make it resume executing.