This code used to work, however I think Xcode's new ARC may have killed it
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    CGDirectDisplayID displayID = CGMainDisplayID();
    CGImageRef image = CGDisplayCreateImage(displayID); //this is a screenshot (works fine)
    [self savePNGImage:image path:@"~/Desktop"];
}
-(void)savePNGImage:(CGImageRef)imageRef path:(NSString *)path {
    NSURL *outURL = [[NSURL alloc] initFileURLWithPath:path]; 
    //here xcode suggests using __bridge for CFURLRef?
    CGImageDestinationRef dr = CGImageDestinationCreateWithURL ((__bridge CFURLRef)outURL, (CFStringRef)@"public.png" , 1, NULL);    
    CGImageDestinationAddImage(dr, imageRef, NULL);
    CGImageDestinationFinalize(dr);
}
This code returns the error:
ImageIO: CGImageDestinationAddImage image destination parameter is nil
which I assume means the CGImageDestinationRef is not being created correctly. I haven't been able to find an implementation of this that the new Xcode doesn't give the same error for, what am I doing wrong?