Converting to ARC and blocks
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