I have the following code:
{
NSObject *_object;
}
- (instancetype)init {
if (self = [super init]) {
_object = [[NSObject alloc] init];
}
return self;
}
- (NSObject*)object {
return _object;
}
If the method object
is called from a second thread after init
has completed and returned, how do I know the assignment to _object
within init
will be visible and it's not actually returning an unassigned pointer?
What is the internal mechanism that guarantees this?