I am creating an NSDictionary with -initWithObjectsAndKeys:.
For every object I provide to that dictionary I call a selfmade method -createFooBarObject, which will create and return the object.
Now the problem: The create method by definition should not release the object because it must return it, and the caller is responsible for releasing it. But here, the caller has no chance to release it because the NSDictionary sucks it in immediately. I call that create-method right inside the -initWithObjectsAndKeys: list of objects and keys, so I have no chance to call -release after adding to the dictionary. Well I could iterate over the dictionary and release them all. But that's ugly.
So is it valid to -autorelease before returning in the -createFooBarObject method? I'm not sure at which point the -autorelease would take place. But it shouldn't happen before the dictionary was created and retained that object. Any idea?