Possible Duplicate:
alloc, init, and new in Objective-C
There is +alloc/-init... and +new. Their role are almost same in documentation except +new is designed for instance pooling. (according to my understanding 🙂
However the pooling is possible with +alloc/-init. Why the separated method is required? Or is there any reason for the method?
And I couldn’t find any example utilizes the method. When should I use this method? Can I get some use-case of the method +new?
In the original Objective-C implementation from Stepstone,
+newwas what we used to create instances. It was a holdover from Smalltalk. NeXT separated+newinto+alloc/-initsince most classes don’t have to do anything different to allocate the memory their instances use, and it didn’t make sense to duplicate that code all over the place.