Re: Correct way to use contextInfo with ARC
Re: Correct way to use contextInfo with ARC
- Subject: Re: Correct way to use contextInfo with ARC
- From: Ron Hunsinger <email@hidden>
- Date: Thu, 04 Aug 2011 16:07:44 -0700
On Aug 3, 2011, at 6:38 PM, Kevin Bracey wrote:
> NSMutableArray *someInfo = [NSArray arrayWithObjects:@"made" , @"it", @"across",. nil];
Did you really want to create an NSArray (non-mutable) and then pass it off as an NSMutableArray? Since you mentioned ARC, I'm surprised the compiler didn't flag the type mismatch. You might have better luck creating the NSMutableArray that your completion routine seems to be expecting:
NSMutableArray *someInfo = [NSMutableArray arrayWithObjects:@"made" , @"it", @"across",. nil];
[holdAlert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(
alertDidEnd:returnCode:contextInfo: ) contextInfo:someInfo;
-(void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
NSMutableArray *holdArray = (NSMutableArray*)contextInfo;
...
}
Or, if the array doesn't really need to be mutable, use NSArray throughout. The only reason to make it mutable would be so the completion handler could use it to pass information back, but of course it has the delegate itself for that.
Or, use a block. That might be simpler still._______________________________________________
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