Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are UIKit delegates "assign"ed instead of "weak"?

As the title states, why are UIKit delegates (assign) instead of (weak)?

See UIPopovercontroller.h for example:

@property (nonatomic, assign) id <UIPopoverControllerDelegate> delegate;

As far as I can tell this provides no benefits over a weakly retained property but a lot of problems where the delegate needs to manage it's own lifetime as a delegate. It this a backwards compatibility issue?

Thanks

like image 942
EightyEight Avatar asked Nov 13 '12 23:11

EightyEight


2 Answers

Because most of those properties existed before the iOS SDK supported weak properties. The weak attribute is only supported on iOS 5.0 and later.

I would have to guess that once iOS 4.x and earlier is history, they will all be updated to weak.

like image 174
rmaddy Avatar answered Oct 25 '22 10:10

rmaddy


UIKit is still built without ARC, therefore none of the UIKit classes can use weak references. Even newer classes like UICollectionView use assign for their delegate properties for this reason.

like image 41
Tuomas Artman Avatar answered Oct 25 '22 10:10

Tuomas Artman