I am using CGRect
, CGPoint
types in my project several times. I can nill the swift objects but i cant set nil values to C
types. How can i free CGRect
and CGPoint
from swift?
Asked
Active
Viewed 448 times
7

Alexey Pichukov
- 3,377
- 2
- 19
- 22

Antony Ouseph
- 552
- 4
- 10
-
4You don't need to, they're not classes. – Jean-Philippe Pellet Jan 07 '16 at 08:01
-
You can't nil objects if they're not declared as optional. You can nil-ify only optionals (either objects or value types). – Cristik Jan 07 '16 at 08:13
1 Answers
4
CGrect
, CGPoint
etc are so called value types. You do not need to worry about releasing them really. You can consider value-type variables to be allocated on stack and therefore being thrown away the moment you leave the scope of a method.
There is a short article at the swift blog that explains the difference between value types and reference types.
Automatic Reference Counting applies to reference types only. There you can consider objects to be allocated on heap.

0x416e746f6e
- 9,872
- 5
- 40
- 68