Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to understand which object self belongs to in objective c?
using this code as an example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
What does self.window refer to? With what class can self be replaced so that the functionality is the same?
Answer the question
In order to leave comments, you need to log in
self
- a pointer to itself. if you write "-" in the body of the call ( -(void)doSmth
), then self is a pointer to the current instance of the class (everything is a little different with class methods, but this is not about that now). In any case, it self
is used for method calls (property, sometimes even ivar) in the code of this method.
There is nothing to replace it and there is no need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question