objective c - Ownership modifiers with manual reference counting -


what happens when use objective-c onwership modifiers (__strong, __weak, __unsafe_unretained) manual reference counting? of them modify behavior of ignored?

clang -e -dm shows definitions of built-in macros:

 $ clang -e -dm -x objective-c /dev/null | egrep  "weak|strong|unsafe" #define __strong  #define __unsafe_unretained  #define __weak __attribute__((objc_gc(weak))) 

as can see, __strong , __unsafe_unretained defined empty macros, , __weak defined (as understand it) relevant in (no longer supported) garbage-collected environment.

so in short: ownership modifiers ignored manual reference counting. makes sense because your responsibility maintain reference counts.

the situation different properties:

@property(strong) id x;            // same "retain" @property(weak) id y;              // syntax error mrc @property(unsafe_unretained) id z; // same "assign" 

and sake of completeness: arc ownership modifiers built-in macros defined follows:

 $ clang -e -dm -x objective-c -fobjc-arc /dev/null | egrep  "weak|strong|unsafe" #define __strong __attribute__((objc_ownership(strong))) #define __unsafe_unretained __attribute__((objc_ownership(none))) #define __weak __attribute__((objc_ownership(weak))) 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -