First Point:
If you are familiar with C++ code, when you create an object, basically you create a new instance of that class as follows:
ClassA object1= new ClassA();
new
is nothing but alloc+init
in the objective-C
ClassA *object1 = [[ClassA alloc] init];
Second Point:
[NSString stringWithString:@"some string"]
It is equivalent to
[[NSString alloc] initWithString:@"some string"]
Here is some more information:
alloc : Class method of NSObject. Returns a new instance of the receiving class.
init : Instance method of NSObject. Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.
new : Class method of NSObject. Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object.
release : Instance method of NSObject delegate. Decrements the receiver’s reference count.
autorelease : Instance method of NSObject delegate. Adds the receiver to the current autorelease pool.
retain: Instance method of NSObject delegate. Increments the receiver’s reference count.
copy : Instance method of NSObject delegate. Returns a new instance that’s a copy of the receiver.
So to conclude we can say that
alloc goes with init
new = alloc + init
More information could be found https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/Initialization/Initialization.html