• 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
Converting to ARC and blocks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting to ARC and blocks


  • Subject: Converting to ARC and blocks
  • From: Steve Mills <email@hidden>
  • Date: Mon, 02 May 2016 17:38:07 +0000 (GMT)

I'm working on a project that's had to support older hardware/software until now, so we can *finally* convert to ARC. Since it's been almost a year since I've worked on anything that used ARC, I'm a little rusty on some of the stranger stuff, like __unsafe_retained. Here's a pared down hunk before converting to ARC:

NSXMLElement* root = [NSXMLNode elementWithName:@"manifest" children:nil attributesWithDict:@{@"thing":@"stuff"}];

__block NSXMLElement* rezes = [NSXMLNode elementWithName:@"resources"];
__block NSXMLElement* rez;

[root addChild:rezes];

[indices enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL* stop) {
   rez = [NSXMLNode elementWithName:@"resource" children:nil attributesWithDict:@{@"identifier":item}];
   [rezes addChild:rez];
   [self _addQTIManifestResources:images addResourcesToNode:rezes];
}];

After using Edit->Convert->To Objective-C ARC, the 2nd line was changed to:

__unsafe_unretained NSXMLElement* rezes = [NSXMLNode elementWithName:@"resources"];

I've looked around, but can't find anything that explains why __unsafe_retained is needed AND why __block is NOT needed.

Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________

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


  • Follow-Ups:
    • Re: Converting to ARC and blocks
      • From: John McCall <email@hidden>
  • Prev by Date: Yosemite NSCollectionView appropriate for spreadsheet-like view?
  • Next by Date: Re: Converting to ARC and blocks
  • Previous by thread: Re: Yosemite NSCollectionView appropriate for spreadsheet-like view?
  • Next by thread: Re: Converting to ARC and blocks
  • Index(es):
    • Date
    • Thread