Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to free CGRect, CGPoint types in swift?

Tags:

ios

swift

cgrect

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?

like image 414
Antony Ouseph Avatar asked Jan 07 '16 07:01

Antony Ouseph


1 Answers

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.

like image 71
0x416e746f6e Avatar answered Nov 07 '22 20:11

0x416e746f6e