What is the difference between [Class new] and [[Class alloc] init] in iOS? [duplicate]

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)