(See this answer for an explanation what oneway
does.)
Your first example doesn't even compile, as void
!= nil
. But if you simply call release
two times on an object that has a retain count of 1, it'll for sure crash.
As for why release
returns void
while autorelease
returns id
: The first says I don't need this object any more, you may get rid of it. Thus, if it would return something and you would operate on it you're likely to operate on a dead object. By contrast, autorelease
more or less says "Soon I won't be needing the object any more but let it stick around until I'm done with the current method."
So as you see they are similar in that they say I won't be needing this object any more, but they differ in the time: release
says "you can get rid of the object now", while autorelease
says "you may get rid of the object later".