carllindberg
carllindberg
Yes, passing a reference to self in a method call from -dealloc is dangerous. You have to be sure that the value is not autoreleased in the calling code (or...
Passing references to self to other methods in dealloc is inherently dangerous. If you are calling ARC code, it will automatically try to retain and then release the argument, but...
If the __weak is a problem perhaps we could use the internal function objc_storeWeakOrNil explicitly to check (and call it with with nil right after). That function is (privately) available...
The code that is "broken" is Apple-required code before iOS 9, and a code pattern which is still supported by Apple. It works fine with the real calls, which are...
@imhuntingwabbits It used to be required to call [[NSNotifcationCenter defaultCenter] removeObserver:self] in your dealloc method. That was correct code which likely still exists in many many codebases, and still works...
> > It used to be required to call [[NSNotifcationCenter defaultCenter] removeObserver:self] in your dealloc method. > It still is as far as I know for manual retain / release...
I agree with all that. But you say: > However this is valid: > > ``` > id mock = [OCMock partialMockForObject:[NSNotificationCenter defaultCenter]]; > id observer = //some object alloc...
> ``` > //just spitball'ing, not sure this compiles but in MRR this dance works like this, maybe arc needs __weak here? > id fooRef = foo; > [[mock expect]...
The additions to check pointers would avoid the need for OCMOCK_ANY in the test case, which would be nice. But that wouldn't solve the crash either way (just make the...
It looks like we are going back to calling _isDeallocating directly, which may crash on older OSes.