• 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: Going back to non-ARC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Going back to non-ARC


  • Subject: Re: Going back to non-ARC
  • From: John Brownie <email@hidden>
  • Date: Sun, 14 Jun 2015 09:22:00 +1000

After much trial and error, I seem to have everything working again, back under ARC. The problem was a macro that was too ambitious for Cocoa:

    NCFOBJECT_OPERATOR(NSArrayRef)

which expands to:

 inline NCFObject(NSArrayRef cfObject) {
         InitializeSelf(cfObject, false);
     }
 inline operator NSArrayRef(void) const {
         return((NSArrayRef) mObject);
     }

(NSArrayRef is defined as typedef NSArray *NSArrayRef;)

It was being used for NSArray, NSData, NSDate, NSDictionary, NSNumber and NSString. It works for Core Foundation objects, since they can all be cast to CFTypeRef, but it seems to require more specific casts in Cocoa to get the bridging to work under ARC.

I fixed it by manually expanding it for each case, with appropriate casts, such as:

    inline NCFObject(NSArrayRef cfObject) {
        InitializeSelf((__bridge CFArrayRef)cfObject, false);
    }
    inline operator NSArrayRef(void) const {
        return (__bridge NSArrayRef)mObject;
    }

Nano itself needs a fair bit of work to compile with ARC, so I'm only patching this one show-stopper for me. Hopefully it's sufficient to make it all work for me, but limited testing shows that earlier memory errors have been fixed by this.

Thanks for the pointers that eventually led to a solution.

John
--
John Brownie, email@hidden or email@hidden
Summer Institute of Linguistics      | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea                     | Papua New Guinea
_______________________________________________

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: 
 >Going back to non-ARC (From: John Brownie <email@hidden>)
 >Re: Going back to non-ARC (From: Sean McBride <email@hidden>)

  • Prev by Date: Re: Language options: Objective-C, Swift, C or C++?
  • Next by Date: Re: NSFontPanel for a modal window
  • Previous by thread: Re: Going back to non-ARC
  • Next by thread: rangeOfString with .RegularExpressionSearch not matching begin and end of line (Swift)
  • Index(es):
    • Date
    • Thread