Why can self be used in implementation methods, or in class methods? What's the internal structure of self? eg:
#import "Person.h"
@implementation Person
+ (void)initialize
{
[super initialize];
[self setupModel];
}
- (instancetype)init
{
self = [super init];
if (self) {
[self test];
}
return self;
}
+ (void)setupModel
{
NSLog(@"setup a person object");
}
- (void)test
{
NSLog(@"this method is called");
}
@end
Code run results: 2018-09-17 09:32:40.615578+0800 Test[662:301213] setup a person object 2018-09-17 09:32:40.615662+0800 Test[662:301213] this method is called