[[+content_image]]
A
A
archiewahwah2015-04-08 15:30:38
Objective-C
archiewahwah, 2015-04-08 15:30:38

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

[[+comments_count]] answer(s)
A
Alexander D., 2015-04-08
@archiewahwah

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 selfis 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.

O
one pavel, 2015-04-08
@onepavel

It looks like you're not very good at programming. What do you want to replace self for?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question