| Start |
|---|
| Automatic Reference Counting With automatic reference counting (ARC), the compiler inserts The sample program from Manual Memory Management looks like this with ARC: You are still able to override the dealloc method to clean up resources not handled by ARC. Unlike when using manual memory management you do not call |
| Strong and weak references A weak reference looks like one of these: If you have a weak reference to an object, then under the hood:
Object references are always strong by default. But you can explicitly specify that they're strong: A strong reference means that while that reference exists, you are retaining the object. |
| Manual Memory Management This is an example of a program written with manual memory management. You really shouldn't write your code like this, unless for some reason you can't use ARC (like if you need to support 32-bit). The example avoids |
| Memory management rules when using manual reference counting. These rules apply only if you use manual reference counting! By calling a method whose name begins with `alloc`, `new`, `copy` or `mutableCopy`. For example: That means that you are responsible for releasing these objects when you are done with them. This makes only sense in some rare situations. For example when you implement an accessor or an init method to take ownership: We have created a string without taking ownership. The It is necessary to use autoreleasepool blocks because you sometimes have objects that you don't own (the fourth rules does not always apply). Automatic reference counting takes automatically care of the rules so you don't have to. |
Read Article
https://develop.horje.com/learn/1434/reference