NSInvocation in a sheet
NSInvocation in a sheet
- Subject: NSInvocation in a sheet
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 22 Aug 2007 18:17:32 +0200
In a subclass of NSDocument I do:
- (void)saveToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName....
{
// do some checking
if ( all_is_fine ) // just do it
{
[ super saveToURL: absoluteURL ofType: typeName... // works as
expected
}
else // ask the user, if they really know what they are doing
{
SEL selector = @selector(saveToURL:ofType:f...) ;
NSMethodSignature *signature = [ self methodSignatureForSelector:
selector ];
NSInvocation *inv = [ NSInvocation invocationWithMethodSignature:
signature ];
[ inv setSelector: selector ];
[ inv setArgument: &absoluteURL atIndex: 2 ];
[ inv setArgument: &typeName atIndex: 3 ];
....
[ inv retainArguments ];
[ inv retain ];
NSLog(@"%s NSInvocation %p %@",__FUNCTION__, inv, inv); // looks ok
NSBeginAlertSheet(...., inv, msg );
}
}
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo;
{
NSInvocation *inv = contextInfo;
NSLog(@"%s NSInvocation %p",__FUNCTION__, inv); // address is ok
NSLog(@"%s NSInvocation %@",__FUNCTION__, inv); // this does crash
// "inv" is not a valid object anymore; the isa pointer is messed up
}
So: what am I doing wrong?
What can I make better?
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden