• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1109
  • Last Modified:

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
0
pegasys
Asked:
pegasys
  • 3
1 Solution
 
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:
I've managed to resolve this myself...

Thanks for trying.
0
 
pegasysAuthor Commented:
self solution
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now