Cocoa Document Based / Core Data App

Hi,

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:

-------------------------------------------------------------------------------------
myAppDelegate.h:

#import

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

myAppDelegte.m:

#import "myAppDelegate.h"

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

- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
{
return NO;
}
@end
-------------------------------------------------------------------------------------

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.

Cheers

De
LVL 7
pegasysAsked:
Who is Participating?
 
pegasysConnect With a Mentor Author Commented:
I've managed to resolve this myself...

Thanks for trying.
0
 
pgnatyukCommented:
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.
0
 
pegasysAuthor Commented:
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?
0
 
pegasysAuthor Commented:
self solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.