Cocoa Document Based / Core Data App

Posted on 2011-10-23
Last Modified: 2012-05-12

I'm just getting to grips with Cocoa dev for Mac OSX and am trying to get my head wrapped around document based apps.

I'm using Xcode 4.2 on OSX Lion 64-bit.

I started a new project, Document Based/Core Data app (for Mac OSX). When I run the templates app, the app starts with an untitled document.

I've tried to impliment applicationShouldOpenUntitledFile and/or applicationOpensUntitledFile (found in NSApplication.h) to set it to NO.

I don't quite see why my AppDelegate isn't being called.

Here's what I did:

1) Start a blank project Cocoa, Core Data/Document Based
2) Create a new class which appears as follows:



@interface myAppDelegate : NSObject
-(BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender;
-(BOOL)applicationOpenUntitledFile:(NSApplication *)sender;


#import "myAppDelegate.h"

@implementation myAppDelegate
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
return NO;

- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
return NO;

3) Built and ran the app with a breakpoint in the class (MyAppDelegate).. I've tried a breakpoint in various places.

The app doesn't even bother calling the MyAppDelegate at all?

Where am I going wrong?

What I'm trying to achieve is that my ApplicationController and APplicationDelgates are custom as opposed to the ones in AppKit.


Question by:pegasys
    LVL 33

    Expert Comment

    Add NSLog(@"I'm here"); to the places you need and check if you see this messages in the console.
    Command+\ to set a breakpoint.
    Check in the Xcode menu that the breakpoints are activated.
    Create the simplest Mac OS project (command line tool) and check if you can stop this app in the debugger.
    LVL 7

    Author Comment

    That works A.O.K. it has something to do with it being document based as AppDelegate isn't automatically created such as in a non-document based.

    If I physically go into NSAPplication.h in the AppKit and hardcode "no" into applicationShouldOpenUntitledFile then it works.

    Where do I tell my app that MyAppDelegate is the app delegate and NOT NSApplicationDelegate?
    LVL 7

    Accepted Solution

    I've managed to resolve this myself...

    Thanks for trying.
    LVL 7

    Author Closing Comment

    self solution

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Collect votes on smartphones 2 381
    Mounting AFP share 2 312
    Deploy iOS App with dev certificate 3 502
    IOS development 3 75
    Preface   In the first 100 days of the Macintosh release in January 1984, Apple sold 72,000 of the computers. Relatively cheap, easy-to-use personal computer with a graphical operating system. I've never seen this model. I did see this one:   …
    CocoaPods is the best way to manage library dependencies in iOS and OS X projects. By using cocoa pods there is no need of downloading the code from github and copying to your project. There are plenty of open source libraries now available with C…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now