|
|
|
|
|
by mpweiher
3697 days ago
|
|
Not just is reference counting a form of garbage collection (as pcwalton pointed out), it is also not the case that you had to retain/release stuff yourself, certainly not since Objective-C 2.0's properties. Here is the code to define and use a property pre ARC with properties: @property NSString *name;
...
object.name = @"Marcel";
And here is the same code with ARC: @property NSString *name;
...
object.name = @"Marcel";
Spot the difference? Now it turns out that there are some differences, such as automatic generation of -dealloc methods and weak references and some cosmetic stuff. But overall, it's at best a subtle difference and for most code you won't be able to tell the difference.Pre Objective-C 2.0, there were solutions such as AccessorMacros[1], which handled the same use-cases except without the dot syntax (which is somewhat questionable) and have the advantage of being user-defined and user-extensible, so for example if you want a lazy accessor, you don't have to wait for your liege lord, er language supplier to add them, or create a whole new language to do the trick. Instead, you just write 4-5 lines of code and: done! [1] https://github.com/mpw/MPWFoundation/blob/master/Classes/Acc... |
|