In addition to the two-segment construction method that uses Alloc to allocate memory and initialize with INIT, the OC provides a way to create objects like new in C + + and Java, new consolidates two invocations of alloc and INIT, simplifying the code.
// main.m
// 06_new
////
Created by Apple on 14-11-11. Copyright (c) 2014 CC. All rights reserved.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool { C13/>//OC also provides a way to create objects in C + + and Java
//new equivalent to calling the Alloc method before calling the Init method, simplifying the operation of the two constructs as a step, the following is the explanation in the API
// Allocates a new instance of the receiving class, sends it an INIT message, and returns the initialized object.
nsstring* str = [NSString new];
}
return 0;
}