Without ARC-enabled, we write
NSArray *items = [[NSArray alloc] initWithObjects:
@"a",
@"b",
@"c",
@"d",
nil];
self.allItems = items;
[items release];
I just wonder whether we can take a shortcut with ARC-enabled like this:
self.allItems = [[NSArray alloc] initWithObjects:
@"a",
@"b",
@"c",
@"d",
nil];
Can we eliminate items when we use ARC? What’s the best practice?
Yes, you can eliminate the
itemsvariable if you’re using ARC. I suggest you eliminate it if you don’t need it elsewhere and you don’t think it makes your code easier to understand. I would definitely eliminate it in your example.