« What is wrong with this picture ? | Main | MulleImagePrinter released »

[NSEnumerator nextObject] vs. [NSArray objectAtIndex:]

One can probably write books about this subject.

I am not sure since when, but -[NSEnumerator nextObject] at least when enumerating an NSArray is returning an autoreleased object. Is this something new or has this been done since the dawn of time ? This pisses me off annoys me greatly, because autoreleased objects make it harder for me to debug. I prefer my objects to dealloc as soon as possible, because if they fail, I have a useful stacktrace.

So I rewrote many of my non-critical loops to use the familiar for(;;) -[NSArray objectAtIndex:] "pattern". (I am surely not using Foundation code for any of my critical loops, he he)

The question I asked myself is this though.:Why is -NSArray objectAtIndex:] not returning an autoreleased object ? It is inconsequential to return an autoreleased object in -[NSEnumerator nextObject] but not in -NSArray objectAtIndex:].

Should I file a bug for orthogonality and misery ? I don't think so. Let sleeping poodles lie.

About

This page contains a single entry from the blog posted on March 28, 2006 6:01 PM.

The previous post in this blog was What is wrong with this picture ?.

The next post in this blog is MulleImagePrinter released.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34