10

I found an interesting post describing how, in Objective-C 2.0, instance variables can be declared in the implementation file. Consider this example:

@interface MyClass {}
@end

@implementation MyClass {    
  NSObject *obj1;
  NSObject *obj2;
}
@end

Notice the ivars obj1 and obj2 are not declared properties. Since they are not declared with an @property statement, there are no corresponding ownership qualifiers such as weak/strong.

My question is, will a project using Automatic Reference Counting (ARC) remember to clean up objects declared in this manner? Any documents addressing this specific issue would be appreciated.

Community
  • 1
  • 1
ocarlsen
  • 1,159
  • 2
  • 15
  • 19

1 Answers1

15

Yes, these implicitly have a __strong in front of them. ARC will deal with them just as you'd expect from a strong property. The appropriate section in the docs is 4.4.1. Objects.

Koen.
  • 23,152
  • 6
  • 79
  • 76
Joshua Weinberg
  • 28,440
  • 2
  • 96
  • 90