Reputation: 11053
I have to convert simple ARC code to non ARC. While it was relatively straight forward I missed an instance variable assignment self.var = xxx, instead I wrote var = xxx.
While in the ARC version it did not cause any trouble - in the non ARC version it certainly caused a crash.
Does that mean that it is actually OK to assign instance vars in ARC without the self. so they get retained?
Thanks!
ps what's the best source to learn how to program in ARC so one avoids abvious errors - so far I did not find any problem at all but I am getting nervous that I might have missed something
Upvotes: 2
Views: 1307
Reputation: 7501
Automatic Reference Counting forbids explicit message send of ‘dealloc’
I have shared a trick to enable older library compilation in new iOS5 SDK.
Click on the Project.
Click on the target.
Select build phases tab.
Select the multiple files in which you want to turn off ARC.
Press ENTER / Hit Enter key
Type “-fno-objc-arc” ( without quotes, as shown in image )
Upvotes: 0
Reputation: 13999
Does that mean that it is actually OK to assign instance vars in ARC without the self. so they get retained?
Yes, kind of.
id obj_;
It is same as this.
id __strong obj_;
obj_ has strong reference for assigned object. The assigned object will not be dealloc-ed until the owner object for the ivar is dealloc-ed.
Please refer to LLVM document or the Apple's ARC reference that is still under NDA.
Upvotes: 1