When I control-drag outlet from xib, I got unsafe_unretained property by default. I'm using Xcode 9.1. The following code is what it looks like.
@property (unsafe_unretained, nonatomic) IBOutlet UILabel *shIndexLabel;
When I control-drag outlet from xib, I got unsafe_unretained property by default. I'm using Xcode 9.1. The following code is what it looks like.
@property (unsafe_unretained, nonatomic) IBOutlet UILabel *shIndexLabel;
__unsafe_unretained specifies a reference that does not keep the referenced object alive and is not set to nil when there are no strong references to the object. If the object it references is deallocated, the pointer is left dangling.
Above excerpt from Apple docs. So answering your question WHY?
It is not possible for the Swift compiler to know if these references are really intended to be strong (+1) or unretained (+0)
This change involved with respect to the swift compiler. They made __unsafe_unretained by default.
Actually, it's a bug of Xcode. It seems unsafe_unretained
will appear when project didn't complete indexing. So we should change it to weak
manually.