What is the different between these two when using ARC in Objective-C for iOS?

NSMutableArray *anArray = [[NSMutableArray alloc] initWithArray:itemsArray];
appDelegate.wishlistItemsArray = anArray;

vs

appDelegate.wishlistItemsArray = [NSMutableArray arrayWithArray:itemsArray];

The property in appDelegate is:

@property (nonatomic, strong) NSMutableArray *wishlistItemsArray;
有帮助吗?

解决方案

Nope. Those methods differ only in the memory management semantics of their return value, and ARC handles memory management for you, they can be used interchangeably in an ARC program.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top