For future reference, I needed to end editing in the textView or the combo 
boxes to prevent the NSInvocation error.  I did this by making the window the 
firstResponder in my NSDocument class with the saveDocumentWithDelegate method 
only when the window is being closed.  This is not necessary when the document 
is just being saved.

Here's the code

- (void)saveDocumentWithDelegate:(id)delegate 
didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo {
        
        // Try to end editing
                        
        if (didSaveSelector == @selector(_document:shouldClose:contextInfo:)) { 
                NSWindow *w = [headerBox window];       
                BOOL ended = [w makeFirstResponder:w];
                if (!ended) {
                        NSLog(@"Could not end editing in 
MyDocument:saveDocumentWithDelegate:");
                        return;
                }
        } 
        
        
        
        [super saveDocumentWithDelegate:(id)delegate 
                                        didSaveSelector:didSaveSelector
                                                contextInfo:(void 
*)contextInfo];
        

}  

On Apr 10, 2010, at 9:12 PM, Jerry Krinock wrote:

> 
> On 2010 Apr 10, at 12:43, Brad Stone wrote:
> 
>> I have a strange bug that I've been tracking for a while and I'd like the 
>> benefit of your experience.  It happens with I close a window that needs to 
>> be saved.
>> 
>> When closing a dirty Core Data NSPersistentDocument I get the following 
>> error between the "Do you want to save" sheet and the save panel:
>> 
>> [58341:a0f] +[NSInvocation invocationWithMethodSignature:]: method signature 
>> argument cannot be nil
> 
>> If I make the document dirty by typing text into any of the combo boxes or 
>> the text view I get the above error after I press the "Save" button on the  
>> "Do you want to saveā€¦"  sheet
> 
> Well, as usual, there are two routes to attack this.  I was going to say to 
> try either, but in this case, since you know it has something to do with the 
> combo boxes or text view, I'd try Route 2 first.
> 
> Route 1 - The Scientist.  Use debugging information to try and narrow down 
> where the problem might be.  To do this, set breakpoints on the following 
> symbols.  (Some are irrelevant for this case, but you should have these handy 
> in any project):
> 
> handleFailureInMethod:object:file:lineNumber:description:
> objc_exception_throw
> malloc_printf
> -[NSException raise]
> handleFailureInFunction:file:lineNumber:description:
> raise:format:arguments:
> 
> Then "Debug - Breakpoints On".  Reproduce your problem, and the debugger will 
> stop where the exception occurs.  Look at the call stack and think real hard. 
>  To get more food for thought, in your Xcode documentation browser, search 
> for and open the "Document-Based Applications Overview".  Click on the 
> chapter, "Message Flow in the Document Architecture", then scroll down to and 
> feast your eyes upon Figure 6.
> 
> Route 2 - The Engineer.  Figure out what you're doing that's different than 
> what everyone else is doing, and change your design toward the more 
> conventional until the problem goes away.  You didn't say much about how 
> you're binding these combo boxes and text view.  Look at Apple's 
> DepartmentAndEmployees sample code, in the MyDocument.nib, and note how the 
> DepartmentController, an NSObjectController, is interposed between the user 
> interface and the data model.  One reason to do that is so that your data 
> model will be updated when the window is closed, and then you won't need to 
> do this:
> 
>> have the bindings set, in IB, to "Continuously Updates Value".
> 
> which is definitely *not* conventional.  (Again, look at the bindings in 
> DepartmentAndEmployees MyDocument.nib.)  Other reasons may be related to your 
> current problem.
> 
> _______________________________________________
> 
> 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/cocoa-dev%40softraph.com
> 
> This email sent to cocoa-...@softraph.com

_______________________________________________

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 arch...@mail-archive.com

Reply via email to