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.
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.
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.
I realise that this is stupid now, and that I shouldn't be releasing something I don't own.
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.
© 2022 - 2024 — McMap. All rights reserved.