Skip to content

Instantly share code, notes, and snippets.

@qy1010
Created November 21, 2019 12:08
Show Gist options
  • Save qy1010/627587c613f3e37be242b0a452e79ed0 to your computer and use it in GitHub Desktop.
Save qy1010/627587c613f3e37be242b0a452e79ed0 to your computer and use it in GitHub Desktop.
//可以看出class_createInstance和alloc的不同
id theObject = class_createInstance(NSString.class, sizeof(unsigned));
id str1 = [theObject init];
NSLog(@"%@", [str1 class]);
id str2 = [[NSString alloc] initWithString:@"test"];
NSLog(@"%@", [str2 class]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment