Reputation: 143
For example,
- (void) method
{
NSString *string = @"This is a string.";
}
Do I need to add
string = nil;
at the end of the method in order to let ARC release it?
Situation may be different in non-literal object such as
- (void) method
{
NSData *data = [[NSData alloc] init];
}
Do I need to add at the end
data = nil;
to release it?
Upvotes: 2
Views: 123
Reputation: 62686
You don't need to nil it, but ARC doesn't release it either. Since it's a literal, it's statically allocated in the app's binary. It's never released.
- (void)method {
NSString *string = @"I'm never released because I'm statically allocated";
NSString *arcReleasesMeAfterMyLastSourceRef = [NSString stringWithString:string];
}
Upvotes: 3