In Objective-C or any other language that applies?
I guess what I'm really asking is, is the __weak and const the same in terms of classification? Can I interchange the terms type and lifetime qualifiers when I'm talking about __weak, const, etc?
In C, a type qualifier attaches a quality (an attribute, a property) to a given type. There are three type qualifiers: const (readonly, no writes), volatile (no cache) and restrict (no alias).
Automatic reference counting (for Objective-C) adds four new type qualifiers: __autoreleasing, __strong, __unsafe_unretained and __weak. Because of the nature of ARC — namely, automating memory management — these four type qualifiers attach attributes related to ownership.
I guess what I'm really asking is, is the
__weakandconstthe same in terms of classification?
They’re both type qualifiers but only __weak is an ownership qualifier.
Can I interchange the terms type and lifetime qualifiers when I'm talking about
__weak,const, etc?
No, they’re not interchangeable. All qualifiers listed above are type qualifiers but only the four qualifiers introduced by ARC are also ownership qualifiers.
Note that the LLVM project uses the denomination ownership qualifiers whereas Apple seem to be using lifetime qualifiers instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With