Re: Passing an integer as contextInfo from a sheet
Re: Passing an integer as contextInfo from a sheet
- Subject: Re: Passing an integer as contextInfo from a sheet
- From: Stefan Pantke <email@hidden>
- Date: Thu, 12 Feb 2004 16:21:22 +0100
Yes, it is. I suppose, no cocoa methods will touch your object
reference. It's your turn to do something useful with this ref.
You may in fact pass everything, but:
I _suppose_, some system level debugging tools might get confused
[ and even you after month ;-) ], if the passed object'ss reference
is stupidly followed. Just some thought, no definitive information.
Better pass an NSDictionary with a singleton item. This is better -
since
if your application grows - you may add more information and you have a
fine design. And it's always better to be prepared...
Am 12.02.2004 um 15:44 schrieb Jeremy Dronfield:
I was using the following method to pass an integer from an alert
sheet:
- (IBAction)deleteSelection:(id)sender
{
NSString *warningText = [NSString stringWithFormat:@"Delete %@?",
[sender title]];
int theTag = [sender tag];
NSBeginAlertSheet(warningText, @"Cancel", @"Delete", nil, [skJournal
mainWindow], self,
@selector(didEndDeleteSheet:returnCode:contextInfo:), NULL, theTag,
@"This action cannot be undone.", nil);
}
- (void)didEndDeleteSheet:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
int theTag = (int)contextInfo;
< ...etc >
}
It worked okay, and the integer was passed, even though the compiler
gave me a "pointer from integer without a cast" warning on
NSBeginAlertSheet. So, going by pure guesswork, I changed the argument
to (void *)theTag, and the warning stopped. I know it seems like an
arsey question, but is this correct?
-Jeremy
========================================
email@hidden
theLocustFarm.net:
- fractious fiction at http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.