In the following code fragment, using ARC, how do I get the delegate to live long enough to call the two method?
Current I get a compiler error
Bad receiver type ‘ __autoreleasing id * ‘
I assume I need to do something to make ARC retain the delegate and release it when it done calling but not sure what the right thing to do is.
- (BOOL) requestFromURL:(NSString*)url withDelegate:( id<SimpleDataDelegate>*) delegate
{
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://..."]]
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
if ( error )
{
[delegate gotFailure:data];
}
else
{
[delegate gotResult:data];
}
}];
return YES;
}
I think your method signature should probably be
instead of
Notice the lack of a
*in the first one, in the second parameter. Try that, and see if the error goes away. Report back if not.