this isn't making sense. You need to get to the bottom of this and not just throw in random code which *seems* to work.

For a start how is delegate declared as a property? Show us the definition please, and are you synthesizing it or have you written code for the methods yourself? If you have declared it

        @property( readwrite, retain ) ...

and synthesized it, then far from releasing it early that self.delegate = .. call will be retaining it, whereas your new assignment isn't.

Your original code,

        self.delegate = [ tDelegate retain ]

seems probably wrong if delegate is a retained property, that will just extra-retain it. Your new code

        delegate = tDelegate;

doesn't retain it at all, one of the following should be the right way to do it

self.delegate = tDelegate; // the property mutator does the retain for you delegate = [ tDelegate retain ]; // you do the retain and then assign it [ self setDelegate:tDelegate ]; // which is the same as the first of the three but clearer.

Have you tried NSLog earlier on tDelegate before you set it into self.delegate, what is it then? Have you looked at this in the debugger to see what's going on?

I'd have to agree with Kyle's suggestion to read the memory management documentation again. And single-step your way through those lines, look at the addreses of tDelegate and what ends up in self.delegate.

On Mar 7, 2009, at 1:44 PM, Aaron Wallis wrote:

I've actually found a workaround - it seems that if I use Obj-C 2.0 style properties the objects somehow get released earlier than they should.

in my example I used the code:
self.delegate = tDelegate
where tDelegate is the delegate supplied through the method call.
However, if I just use:
delegate = tDelegate
the script runs fine without a hitch...

it must have something to do with the self.delegate property being set to retain or something?
maybe it's causing the nsautoreleasepool to release early?

On 07/03/2009, at 4:35 PM, Kyle Sluder wrote:

It sounds like you have some sort of memory issue. Since you refer to
things like "NSAutorelease objects" (which don't exist) and are
apparently calling -retain on an object that you immediately assign to
a property, I suggest you go back and re-read the Memory Management
Guide.

--Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to