Lets say I have local variable(not property) Obj *x = d, is d's reference count incremented? Or is it default a weak reference?
答案 0 :(得分:4)
Apple's documentation (Variable Qualifiers
section) said:
__strong is the default. An object remains “alive” as long as there is a strong pointer to it.
答案 1 :(得分:2)
Say you write
__weak NSMutableArray* myArray = [[NSMutableArray alloc] init];
What happens? What happens is that the only reference to that array is in a weak variable, which means it gets deallocated immediately and myArray is set to nil. Now say you write
NSMutableArray* myArray = [[NSMutableArray alloc] init];
What would happen if the default is "weak"? Does that answer your question?
答案 2 :(得分:1)
They are strong by default.