views:

118

answers:

3

i.e. would cause the object to be released immediately and not have to be released by the pool if I did this?

[[NSArray arrayWithCapacity:100] release];

Can't find a clear explanation in the docs about this.

+1  A: 

I realise that this is stupid now, and that I shouldn't be releasing something I don't own.

Ranking Stackingblocks
+1  A: 

It would likely crash when the object would normally be autoreleased. autorelease means "delayed release", so it will be released: just later. Since the object won't exist later as you are manually releasing it, you will likely crash due to the runtime sending the -release message to your now-deallocated object.

Edit: Note that if you -retain objects that come autoreleased, you do have to -release them: you are taking ownership.

chpwn
A: 

If you don't want the object to go into the auto-release pool, you can do a manual alloc and initWithCapabity. If you do that, you'll have to manually release it at some point.

Andy White