Hi,

I still have trouble understanding the autorelease pool.

Lets assume an object Z has a method where it gets a string y and returns 
another string x.

Now when an instance of this object is created and the method is invoked,
 x is returned and is used somewhere else.

Now this method of object Z should not be the owner of x right?
Because x is used elsewhere.


So I add x to the autorelease-pool to declare that I am not the owner (and 
won't send it a release message);

x = [[[NSString alloc] init] autorelease];


but where do I release the pool?
And to which pool is it added?


I thought I would create my own pool in the init-method of Z and send it a 
[pool release] message in the alloc-method.

But I haven't seen that so far in sample code ...



can someone explain me what happens when I add x to the autorelease pool?
And where does it get released when I don't send a release command to the pool?

_______________________________________________

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