On 17 Nov 2008, at 10:44 AM, [EMAIL PROTECTED] wrote:

I am trying to open a defined document type programmatically. Document type is defined in info.plist and opens with UI just fine. I can not get openFileWithoutUI to work. I have read documentation and I find no samples of code. There are several places I could be making an error but I can not see what I may be doing wrong.

1. I set an object: AppController as a delegate of my NSApplication in IB. In MainMenu.NIB if I click on AppController object I see File's Owner in the referencing outlet as a delegate.

2. I have a method in AppController:
- (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename
{
        return [self application:NSApp openFile:filename];
}
3: I call from another controller with the following:
NSApplication* app = [NSApplication sharedApplication];
[app application:self openFileWithoutUI: totalFile];

When this last statement is executed it does not call the AppController:: "application:(id)sender openFileWithoutUI:(NSString *)filename" method.
in Console we get the error:
"-[NSApplication application:openFileWithoutUI:]: unrecognized selector sent to ..."

Probably be something wrong with my delegate set up. Any suggestions?

Read up more on Cocoa's delegate design pattern. application:openFileWithoutUI: and application:openFile: are methods an application _delegate_ may implement. The documentation shows they are delegate methods. They are not methods of NSApplication, and trying to use one on an NSApplication will give you the error you saw, saying that the method isn't there.

You would not (maybe there are exceptions) call delegate methods yourself. It isn't illegal, but it suggests a problem in your design. Cocoa's purpose in having delegate methods is for them to be called from the object that owns the delegate.

        — F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/ >

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to