Re: Dodgy Code - Low Level Memory Management Question!

2016-01-26 Thread Dave
> On 26 Jan 2016, at 19:15, Jens Alfke wrote: > > >> On Jan 26, 2016, at 6:00 AM, Dave > > wrote: >> >> Sorry typeo in the pseudo code, it passes the object and it is retained…. > > Dave, if you want us to debug your code for you, then SHOW US THE ACTUAL > #*$

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-26 Thread Jens Alfke
> On Jan 26, 2016, at 6:00 AM, Dave wrote: > > Sorry typeo in the pseudo code, it passes the object and it is retained…. Dave, if you want us to debug your code for you, then SHOW US THE ACTUAL #*$&% CODE! Don’t show us something else that _looks_ like real Obj-C but that you just typed into

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-26 Thread Quincey Morris
On Jan 26, 2016, at 06:00 , Dave wrote: > > IOW, the autorelease will basically just be a NOP? An autorelease is never a NOP. It’s a “release later”, not a “release if necessary”. Rather than trying to count or balance retains globally, I think it’s easier to think in terms of ownership (+1 r

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-26 Thread Dave
Hi Again \ > On 25 Jan 2016, at 19:22, Quincey Morris > wrote: > > On Jan 25, 2016, at 10:48 , Dave > wrote: >> >> myNewObject = [super initWithSomething: something]; > > This is a dangerous thing to do. At this point ‘self’ might not be a properly > initializ

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-25 Thread Dave
Also, >> [LTWCacheManager addToCache: myID]; Should be [LTWCacheManager addID:myID withObject:myNewObject]; or some such (this is pseudo code really). > On 25 Jan 2016, at 19:06, Jens Alfke wrote: > > >> On Jan 25, 2016, at 10:48 AM, Dave > > wrot

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-25 Thread Dave
Yes, A typeo, sorry! > On 25 Jan 2016, at 19:06, Jens Alfke wrote: > > >> On Jan 25, 2016, at 10:48 AM, Dave > > wrote: >> >> if ( myCachedObject == nil); > > The trailing semicolon on that line above must be a typo. It’s going to cause > the test to be ignore

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-25 Thread Quincey Morris
On Jan 25, 2016, at 10:48 , Dave wrote: > > myNewObject = [super initWithSomething: something]; This is a dangerous thing to do. At this point ‘self’ might not be a properly initialized object, if the ‘super’ call returns a different object from ‘self’. You’re better off assigning the result t

Re: Dodgy Code - Low Level Memory Management Question!

2016-01-25 Thread Jens Alfke
> On Jan 25, 2016, at 10:48 AM, Dave wrote: > > if ( myCachedObject == nil); The trailing semicolon on that line above must be a typo. It’s going to cause the test to be ignored and the block below to always run. > { > self = myNewObject; > [LTWCacheManager addToCache: myID]