• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ARC conversion help - CFErrorRef* and NSError**
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC conversion help - CFErrorRef* and NSError**


  • Subject: Re: ARC conversion help - CFErrorRef* and NSError**
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 29 Oct 2012 14:30:42 -0500

On Oct 29, 2012, at 1:15 PM, Alex Kac wrote:

> ARC conversion is something we're having some issues with, but I won't bore you with the details. I'm trying to convert parts of our project to ARC and so of course there is a learning curve. Primarily between CF code and Cocoa. This one I'm stumped on as I'm just starting the CF/Cocoa _bridging part of my conversion.
>
> + (BOOL) addGroup: (ABGroup *) aGroup withError: (NSError **) error
> {
>     CFErrorRef* cfError = error;
>
>     ABAddressBookRef addressBook = CFAutorelease(WebISSafe_ABAddressBookCreateWithOptions(NULL,NULL));
>     if (!ABAddressBookAddRecord(addressBook, aGroup.record, cfError)) return NO;
>     return ABAddressBookSave(addressBook, cfError);
> }
>
> I'm confused on how to properly bridge the CFErrorRef* and NSError**. I've tried a variety of things, but all give an error. I learn more by example than by definition so the reference docs don't always clarify things for me.

I think you're going to have to use temp variables.

+ (BOOL) addGroup: (ABGroup *) aGroup withError: (NSError **) error
{
    BOOL ret;
    CFErrorRef cfError;

    ABAddressBookRef addressBook = CFAutorelease(WebISSafe_ABAddressBookCreateWithOptions(NULL,NULL));
    if (!ABAddressBookAddRecord(addressBook, aGroup.record, cfError)) return NO;
    ret = ABAddressBookSave(addressBook, &cfError);
    if (!ret && error)
	*error = CFBridgingRelease(cfError);
    return ret;
}

Cheers,
Ken


_______________________________________________

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

References: 
 >ARC conversion help - CFErrorRef* and NSError** (From: Alex Kac <email@hidden>)

  • Prev by Date: Re: App rejection due to app-sandboxing invalid entitlement
  • Next by Date: Re: Warning message using stringWithContentsOfFile:encoding:error:
  • Previous by thread: ARC conversion help - CFErrorRef* and NSError**
  • Next by thread: Re: ARC conversion help - CFErrorRef* and NSError**
  • Index(es):
    • Date
    • Thread