title: Casting a CFErrorRef to an NSError (or opposite) with ARC
body: <p>I used to cast an NSError to CFErrorRef like this and using it in SMJobBless</p>
  
  <pre><code>NSError *error
  BOOL removed = SMJobRemove(kSMDomainSystemLaunchd,
                                 (CFStringRef) daemonBundleID,
                                 auth,
                                 true,
                                 (CFErrorRef*) &amp;error);
  if (!removed) {
          NSLog(@"Failed to remove existing PacketTool");
          [NSApp presentError: error];
      }
  </code></pre>
  
  <p>As I've had errors with ARC, "Cast of an indirect pointer to an Obj-C pointer to 'CFErrorRef' is disallowed with ARC", I changed and decided to do the opposite</p>
  
  <pre><code>CFErrorRef *cfError = nil;
  BOOL blessed = SMJobBless(kSMDomainSystemLaunchd, (__bridge CFStringRef)daemonBundleID,
                            auth,
                            cfError);
  if (!blessed) {
      NSError *error = (__bridge NSError *)cfError;
      NSLog(@"Failed to bless PacketTool: %@", error);
      [NSApp presentError: error];
      return FALSE;
  }
  </code></pre>
  
  <p>Now I've got an "Incompatible types casting 'CFErrorRef' to NSError *" with __bridge cast</p>
  
  <p>What can I do?</p>
  
  <p>Update: Thanks to Greg, correct code is now:</p>
  
  <pre><code>CFErrorRef cfError = nil;
  BOOL blessed = SMJobBless(kSMDomainSystemLaunchd,
                            (__bridge CFStringRef) daemonBundleID,
                            auth,
                            &amp;cfError);
  if (!blessed) {
      NSError *error = (__bridge NSError *)cfError;
      NSLog(@"Failed to bless PacketTool: %@", error);
      [NSApp presentError: error];
      return FALSE;
  }
  </code></pre>