Possible Duplicate:
What is the difference between these two ways of allocating memory in Objective-C?
I got tripped up on this. I realized I don’t understand the concept of when I must use alloc init to create space for an object on the heap.
Via NSSet’s class reference I found the class method “set” (http://goo.gl/ndHjK).
Its description reads “Creates and returns an empty set.”, which sounds like precisely what I want. So does this “set” method implicitly perform an alloc init for me?
Or am I confusing two very different things completely?
[NSSet set]is called a convenience constructor. It returns an autoreleased object, meaning you don’t have to care about memory management for that object, unless you retain it explicitly of course.If you allocate it explicitly, you must also release it.
A convenience constructor looks usually like this: