Is it safe to assign a property to initialization result with auto-implementation when using ARC?

Let's say I have such a strong property:

  @interface Foo
    @property (strong, nonatomic) NSArray *myArray;
  @end

And in my initializer, I set myArray as follows:

myArray = [NSArray array];

It is safe? Will ARC help keep myArray right for me?

I ask that I have a project in which myArray is not saved properly in this scenario, and I get poor memory access along the way.

But if I use

 myArray = [[NSArray alloc] init];

then everything is fine.

+5
source share
1 answer

Yes, ARC will automatically save it for you.

ARC : , . (, ) , .

, ARC , . , , "Zombies". / , , .

+7

All Articles