And why can this vary between debug / release / sim / sim combinations? (Sample code below.)
I inherited some code that "works" in the simulator and on devices in Debug, but not on the device in Release (used with the latest LLVM). This is due to ARC and a weak property (which should have been strong), but I do not quite understand what is happening, and I hope someone can explain this to me and why it changes between Debug / Release / Device / Simulator.
I created a simple sample project demonstrating this, with all the code in AppDelegate.m, as follows. When run in the simulator, the logged output:
-[BaseThingMaker baseMakeThing]: returning a Thing -[ThingMaker makeThing]: returning a Thing -[AppDelegate application:didFinishLaunchingWithOptions:]: got a Thing
When starting on the device, the registered output:
-[BaseThingMaker baseMakeThing]: returning a Thing -[ThingMaker makeThing]: returning a (null) -[AppDelegate application:didFinishLaunchingWithOptions:]: got a (null)
On the device (in Debug or Release), weak self.thing in ThingMaker is zero even for a log message before the method completes. On the simulator, the self.thing object is self.thing .
Sample code from a single-window application (AppDelegate.m):
source share