Re: Documents not opening from Finder
On Mar 2, 2013, at 17:11 , Graham Cox wrote: > Unless you send -retainArguments to it, in which case it, well, does what it > says on the tin. OK, but it's still a bit more complicated than that. Using the override code suggested in the AppKit release notes I linked to, you also have to deal with the management of the 'contextInfo' parameter, which is one of those awkward ARC cases. There are likely also some bridging casts needed, since the 'didSomethingSelector' and 'contextInfo' patterns both gloss over the difference between void* and id. So maybe what I should have said was that NSInvocation needs some hand-holding when used with ARC. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On 03/03/2013, at 11:05 AM, Quincey Morris wrote: > The other gotcha is that NSInvocation doesn't take ownership of any objects > referred to by its arguments. That means being very careful when using ARC, > since it can't memory-manage them for you. Unless you send -retainArguments to it, in which case it, well, does what it says on the tin. What's a bit annoying is that this retains the target as well, so if you want arguments retained but not the target (e.g. in an Undo scenario), you have to do a bit of a dance to workaround it. --Graham ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 2, 2013, at 13:17 , "Mills, Steve" wrote: > But I'm not calling runModalPrintOperation, nor do I want to, because we need > to do something completely different at this point. This is the reason I'm > overriding printDocumentWithSettings in the first place. I just need to know > how to call the selector like I stated before. Take a look at this: https://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKitOlderNotes.html and search for the heading "Advice for Overriders of Methods that Follow the delegate:didSomethingSelector:contextInfo: Pattern". If the code sample makes your eyeballs hurt, I don't blame you. It's the kind of hackery that could be avoided with blocks, but this delegate/selector pattern pre-dates blocks. The other gotcha is that NSInvocation doesn't take ownership of any objects referred to by its arguments. That means being very careful when using ARC, since it can't memory-manage them for you. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 2, 2013, at 1:17 PM, "Mills, Steve" wrote: > On Mar 2, 2013, at 15:06, "Kyle Sluder" wrote: > >> The documentation is pretty clear about how NSDocument's default >> implementation works. -[NSDocument >> runModalPrintOperation:delegate:didPrintSelector:context:] is what actually >> messages the delegate with the didPrintSelector. As long as you are calling >> that method with those arguments (either directly or by calling super in >> your override of -printDocumentWithSettings…), the delegate will be messaged >> appropriately. > > But I'm not calling runModalPrintOperation, nor do I want to, because we need > to do something completely different at this point. That's relevant information that you should really mention upfront. > This is the reason I'm overriding printDocumentWithSettings in the first > place. I just need to know how to call the selector like I stated before. There are two ways: 1. Cast objc_msgSend to (void)(id, SEL, id, BOOL, void*) and call it with the correct arguments. 2. Build an NSInvocation and invoke it. You will probably want to create a dummy implementation of the didPrintSelector so you can get its method signature via -methodSignatureForSelector:. --Kyle Sluder ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 2, 2013, at 15:06, "Kyle Sluder" wrote: > The documentation is pretty clear about how NSDocument's default > implementation works. -[NSDocument > runModalPrintOperation:delegate:didPrintSelector:context:] is what actually > messages the delegate with the didPrintSelector. As long as you are calling > that method with those arguments (either directly or by calling super in your > override of -printDocumentWithSettings…), the delegate will be messaged > appropriately. But I'm not calling runModalPrintOperation, nor do I want to, because we need to do something completely different at this point. This is the reason I'm overriding printDocumentWithSettings in the first place. I just need to know how to call the selector like I stated before. Steve via iPad ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 2, 2013, at 12:16 PM, Steve Mills wrote: > Perhaps the problem is that my > printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo > method doesn't call the selector when we're finished printing. I don't > understand how to call the delegate with that selector and can't find any > examples of this. Any pointers? Code samples? The documentation is pretty clear about how NSDocument's default implementation works. -[NSDocument runModalPrintOperation:delegate:didPrintSelector:context:] is what actually messages the delegate with the didPrintSelector. As long as you are calling that method with those arguments (either directly or by calling super in your override of -printDocumentWithSettings…), the delegate will be messaged appropriately. --Kyle Sluder ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
Perhaps the problem is that my printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo method doesn't call the selector when we're finished printing. I don't understand how to call the delegate with that selector and can't find any examples of this. Any pointers? Code samples? -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 1, 2013, at 14:59 , Steve Mills wrote: > Sorry, I still consider myself a newbie in Cocoaland. I can add those open > and print overrides to my NSApplicationDelegate, but I only want to be able > to set breakpoints on them but still let the default behavior happen. Since > NSApplicationDelegate doesn't actually implement those methods, I can't > simply call [super application:sender openFiles:filenames]; to get that > default behavior. So what do I do? I need everything to work at least once in > the normal way so I can then see which methods might not be getting called > when things start going wrong. Well, yes, good point. Answers are buried in here: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_handle_AEs/SAppsHandleAEs.html#//apple_ref/doc/uid/20001239 under the heading "Apple Events Sent by the Mac OS". That brings us back to AppleEventland, in a sense, but the point is to pull out of this documentation the standard invocations of NSDocumentController or NSDocument methods, and use those in your app delegate methods. Unfortunately, this document appears to date from 10.4 times, but it should lead you to the information you want. In practice, you'll likely only care about providing 2 app delegate methods: 'application:openFile:' (or 'application:openFiles:') and 'application:printFiles:withSettings:showPrintPanels'. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 1, 2013, at 16:21:35, Quincey Morris wrote: > I think the diversion into Apple Events is something of a red herring, at > least at this stage of your debugging. Requests to open and print may indeed > arrive at your app as Apple Events, but the best place to intervene is in > NSApplicationDelegate protocol. By default, all such external requests should > end up at one or other of the delegate protocol methods. > > If they don't get there, it seems likely the Finder isn't sending them. That > wouldn't solve your problem, of course, but it would tell you that looking in > your app's code isn't going to get to the solution. Sorry, I still consider myself a newbie in Cocoaland. I can add those open and print overrides to my NSApplicationDelegate, but I only want to be able to set breakpoints on them but still let the default behavior happen. Since NSApplicationDelegate doesn't actually implement those methods, I can't simply call [super application:sender openFiles:filenames]; to get that default behavior. So what do I do? I need everything to work at least once in the normal way so I can then see which methods might not be getting called when things start going wrong. -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Mar 1, 2013, at 13:59 , Steve Mills wrote: > I have tons of experience with AppleEvents under Carbon, but none under > Cocoa. Where does that event come in? I think the diversion into Apple Events is something of a red herring, at least at this stage of your debugging. Requests to open and print may indeed arrive at your app as Apple Events, but the best place to intervene is in NSApplicationDelegate protocol. By default, all such external requests should end up at one or other of the delegate protocol methods. If they don't get there, it seems likely the Finder isn't sending them. That wouldn't solve your problem, of course, but it would tell you that looking in your app's code isn't going to get to the solution. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
On Feb 28, 2013, at 02:35:18, Uli Kusterer wrote: > Opening internally sends Apple Events. Have you checked whether the"open > document" Apple event is sent and whether it looks any different? My guess is > they won't use that for the open panel, but maybe they do and something's > broken there? I have tons of experience with AppleEvents under Carbon, but none under Cocoa. Where does that event come in? I've added an NSDocumentController subclass to see if any of its document opening methods are being invoked. If I print a document from Finder, these 2 methods are called: -(id) openDocumentWithContentsOfURL:(NSURL*)absoluteURL display:(BOOL)displayDocument error:(NSError**)outError -(id) makeDocumentWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError If I close the document and then open a document via my app's Open Recent submenu, nothing happens and none of them get hit. If I go through the Open menu item, these get hit: -(IBAction) openDocument:(id)sender -(NSInteger) runModalOpenPanel:(NSOpenPanel *)openPanel forTypes:(NSArray *)types -->returns 1 But nothing else happens. To rule out our internal print code, I can open documents via our Open or Open Recent menu items, Print, and Close any number of times and things keep working correctly. It's only when we're commanded to open and print from Finder that things get messed up. Maybe because we don't close the document when we're done, but let the user do it manually? -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Documents not opening from Finder
Opening internally sends Apple Events. Have you checked whether the"open document" Apple event is sent and whether it looks any different? My guess is they won't use that for the open panel, but maybe they do and something's broken there? Cheers, -- Uli Kusterer "The Witnesses of TeachText are everywhere..." http://www.zathras.de On 25.02.2013, at 19:58, Steve Mills wrote: > I'm seeing a situation where, after successfully opening, NOT printing, and > then closing a document x number of times via Finder's Print command, our app > will stop receiving requests to open the same or any other document. I've > added an override for initWithContentsOfURL:ofType:error: just to see if it's > getting there, and it is not. Normally we only override init, > initWithType:error, and readFromURL:ofType:error:. In fact, we stop getting > even the readFromURL:ofType:error: message if I go through our app's standard > Cocoa Open menu item; I choose a file and nothing happens. Same with init and > initWithType:error. > > Any ideas about what could be getting messed up? We subclass > NSApplicationDelegate, NSDocument, and NSWindowController, but nothing else > in the chain like NSDocumentController. > > -- > Steve Mills > office: 952-818-3871 > home: 952-401-6255 > cell: 612-803-6157 > > > > ___ > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/witness.of.teachtext%40gmx.net > > This email sent to witness.of.teacht...@gmx.net ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Documents not opening from Finder
I'm seeing a situation where, after successfully opening, NOT printing, and then closing a document x number of times via Finder's Print command, our app will stop receiving requests to open the same or any other document. I've added an override for initWithContentsOfURL:ofType:error: just to see if it's getting there, and it is not. Normally we only override init, initWithType:error, and readFromURL:ofType:error:. In fact, we stop getting even the readFromURL:ofType:error: message if I go through our app's standard Cocoa Open menu item; I choose a file and nothing happens. Same with init and initWithType:error. Any ideas about what could be getting messed up? We subclass NSApplicationDelegate, NSDocument, and NSWindowController, but nothing else in the chain like NSDocumentController. -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com