Why does Apple use assign rather than weak to store a delegate?

user4951

Some Cocoa and Cocoa Touch classes declare their delegate properties as assign rather than weak, which forces users of the class to nil out the property in dealloc

-(void)dealloc
{
    self.imageScrollView.delegate = nil;
    self.tableView.delegate = nil;
    self.tableView.dataSource = nil;
}

Which is very cumbersome.

Why would Apple do it this way?

Phillip Kinkade

The reason why is that not all system classes have been compiled with ARC.

You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC.

See this page on developer.apple.com: Transitioning to ARC Release Notes

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Angular 6 - Why use @ngrx/store rather than service injection

From Dev

Why does Clojure Spels use quoted symbols, rather than keywords?

From Dev

Why does `libpq` use polling rather than notification for data fetch?

From Dev

Why does Prolog use =< Rather than <= like most languages?

From Dev

Why does Go use ^ rather than ~ for unary bitwise-not?

From Dev

Why does GWT use code generators rather than annotation processors?

From Dev

Why does `libpq` use polling rather than notification for data fetch?

From Dev

Why does Linux use a swap partition rather than a file?

From Dev

Why use pandas.assign rather than simply initialize new column?

From Dev

Why use strings rather than direct method calls to trigger an action in a Redux store?

From Dev

Why do some CLIs use ` and ' rather than ‛ and ’?

From Dev

Why use TimeSpan.CompareTo() rather than < > or =

From Dev

Why use a function rather than a reference to member?

From Dev

Why use ImageIcon rather than Image?

From Dev

Why to use ByteArrayInputStream rather than byte[] in Java

From Dev

Why use "nohup &" rather than "exec &"

From Dev

Why do some CLIs use ` and ' rather than ‛ and ’?

From Dev

Why use Python format rather than slicing?

From Dev

In the regularization,why we use θ^2 rather than θ?

From Dev

Why use regex finditer() rather than findall()

From Dev

Why does Rails use the params variable rather than passing arguments through the function?

From Java

Why does BufferedInputStream copy a field to a local variable rather than use the field directly

From Dev

Why does Java use a static heap rather than allow an arbitrary amount of memory?

From Dev

Why does WatchService use unbound wildcard WatchEvent<?> rather than WatchEvent<Path>

From Dev

Why does Meteor use fibers rather than promises or async or something else?

From Dev

Why does Realm use RealmOptional<Int> rather than Int? for optional properties?

From Dev

Why does Perlin noise use a hash function rather than computing random values?

From Dev

Why does cx_Freeze use Win32GUI rather than Win64GUI?

From Dev

Why can't you assign class attributes as arguments directly to a class parenthesis rather than use the def __init__ method?

Related Related

  1. 1

    Angular 6 - Why use @ngrx/store rather than service injection

  2. 2

    Why does Clojure Spels use quoted symbols, rather than keywords?

  3. 3

    Why does `libpq` use polling rather than notification for data fetch?

  4. 4

    Why does Prolog use =< Rather than <= like most languages?

  5. 5

    Why does Go use ^ rather than ~ for unary bitwise-not?

  6. 6

    Why does GWT use code generators rather than annotation processors?

  7. 7

    Why does `libpq` use polling rather than notification for data fetch?

  8. 8

    Why does Linux use a swap partition rather than a file?

  9. 9

    Why use pandas.assign rather than simply initialize new column?

  10. 10

    Why use strings rather than direct method calls to trigger an action in a Redux store?

  11. 11

    Why do some CLIs use ` and ' rather than ‛ and ’?

  12. 12

    Why use TimeSpan.CompareTo() rather than < > or =

  13. 13

    Why use a function rather than a reference to member?

  14. 14

    Why use ImageIcon rather than Image?

  15. 15

    Why to use ByteArrayInputStream rather than byte[] in Java

  16. 16

    Why use "nohup &" rather than "exec &"

  17. 17

    Why do some CLIs use ` and ' rather than ‛ and ’?

  18. 18

    Why use Python format rather than slicing?

  19. 19

    In the regularization,why we use θ^2 rather than θ?

  20. 20

    Why use regex finditer() rather than findall()

  21. 21

    Why does Rails use the params variable rather than passing arguments through the function?

  22. 22

    Why does BufferedInputStream copy a field to a local variable rather than use the field directly

  23. 23

    Why does Java use a static heap rather than allow an arbitrary amount of memory?

  24. 24

    Why does WatchService use unbound wildcard WatchEvent<?> rather than WatchEvent<Path>

  25. 25

    Why does Meteor use fibers rather than promises or async or something else?

  26. 26

    Why does Realm use RealmOptional<Int> rather than Int? for optional properties?

  27. 27

    Why does Perlin noise use a hash function rather than computing random values?

  28. 28

    Why does cx_Freeze use Win32GUI rather than Win64GUI?

  29. 29

    Why can't you assign class attributes as arguments directly to a class parenthesis rather than use the def __init__ method?

HotTag

Archive