I’m slightly confused as to how ARC works, I know there is automatic reference counting but does this functionality work even for assigning raw instance variables (not using the properties).
For instance, if I have an instance variable arr:
@interface TestClass : NSObject {
NSArray *arr;
}
Now if inside a method I assign this using an auto-released NSArray:
- (IBAction)test {
arr = [NSArray arrayWithObject:@"TEST"];
}
What happens to this array? Does it just magically keep it until arr is reassigned to something else?
Now if I do something like:
self.arr = [NSArray arrayWithObject:@"TEST"];
What happens if it is strong vs. weak?
Yes, ARC works on raw ivar access. Just like local variables, ivars are implicitly
__strongunless decorated with__weakor__unsafe_unretained. Therefore they will, by default, act like a property that’s been markedstrong(orretain, which under ARC is a synonym forstrong).