Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If ARC is handled by the compiler, why is weak not supported on iOS 4 and Mac OS X 10.6?

Supposedly weak is like assign or unsafe_unretained, except that a weak variable is "zeroed" when the object that it points to is dealloc'ed. But ARC is handled by the compiler, so why is weak not supported on iOS 4 and Mac OS X 10.6?

(for this question please don't give a guess as an answer, but something more supported by facts/reference/docs)

like image 420
Jeremy L Avatar asked Nov 30 '25 09:11

Jeremy L


2 Answers

Since __weak requires zeroing out one or more pointers in places other than the current object, additional data structures are required to keep track of weak references. This is in contrast to __strong, __unsafe_unretained, and __autoreleasing, which do not require additional tracking. The tracking structures and programs for manipulating them are built into the OS; the compiler inserts the code to perform the calls, but the OS support needs to be there in order for the compiled code to work.

like image 178
Sergey Kalinichenko Avatar answered Dec 02 '25 23:12

Sergey Kalinichenko


__weak references require runtime support which isn't available on the older iOS versions.

like image 43
Mike Weller Avatar answered Dec 02 '25 22:12

Mike Weller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!