Does ARC ever inject retain and release calls that you generally wouldn’t see in a non-ARC environment?
For example, explicitly releasing an object from a getter:
- (NSArray *)dummyArray {
return [[NSArray alloc]init];
}
- (void)useDummyArray {
NSArray * arr = [self dummyArray];
//do something with arr
[arr release]; //unconventional injection of release.
}
Would ARC ever generate a release statement like the code above or would it autorelease the array returned by [self dummyArray];
The beauty of ARC is that you don’t know, or need to know. However, you can give hints to the ARC static analyzer:
However,
NS_RETURNS_NOT_RETAINEDis the default, as long as your function name doesn’t begin withinit, in whichNS_RETURNS_RETAINEDbecomes default.So, in your specific scenario, it will almost always return an
autorelease‘d value. One major reason for this is support for interpolation with non-ARC code, which could result in leaks.