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: Jeremy Dronfield <email@hidden>
- Date: Thu, 12 Feb 2004 16:55:38 +0000
Thanks for that. It simply never occurred to me to pass "sender". What
a dope. In addition to the caveat you mention, passing sender also
gives me the potential to haul other elements out of contextInfo if
required. Cheers.
- Jeremy
On 12 Feb 2004, at 3:14 pm, Clark Cox wrote:
It's generally a bad idea to assume that an int can be represented by
a pointer or vice-versa. Your code will work on OSX as it currently
stands, but your code is brittle with respect to changes in the sizes
of types. Why not do something like:
- (IBAction)deleteSelection:(id)sender
{
NSString *warningText = [NSString stringWithFormat:@"Delete %@?",
[sender title]];
NSBeginAlertSheet(warningText, @"Cancel", @"Delete", nil, [skJournal
mainWindow], self,
@selector(didEndDeleteSheet:returnCode:contextInfo:), NULL, sender,
@"This action cannot be undone.", nil);
}
- (void)didEndDeleteSheet:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
int theTag = [(id)contextInfo tag];
< ...etc >
}
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[demime 0.98b removed an attachment of type
application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.