The difference between new and alloc/init in iOS development, iosnewallocinit
[ClassName new] is basically equivalent to [[className alloc] init];
The difference is that zone is used when alloc allocates memory.
What is this zone?
When allocating memory to objects, it allocates the associated objects to an adjacent memory area, so as to consume a small amount of money during calls and increase the processing speed of the program;
If new is used, the initialization method is fixed and only init can be called.
What if you want to call initXXX? No! It is said that the initial design fully draws on the Smalltalk syntax.
The new and alloc/init functions are almost the same, allocating memory and completing initialization.
The difference is that the new method can only use the default init method to complete initialization,
You can use other custom initialization methods using alloc.