erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

Avoid retaining return value if it is the mock itself #363

Closed Regno closed 4 years ago

Regno commented 5 years ago

Fixing issue: https://github.com/erikdoe/ocmock/issues/356 In current commit there are: example of the #365 issue and its solution.

When returned object is the same as the mocked object for stub - do not invoke retain. Mocked-object's lifetime is always longer than stub-object’s, therefore we do not worry that stub-object will be freed earlier than mocked-object(aka returned object).

Co-Authored-By: QB victoriaqb@users.noreply.github.com

erikdoe commented 4 years ago

EDIT: Sorry, my previous comment was wrong. I will looking into adding this on top of #360.