user451295
user451295

Reputation: 53

self.view / super.view

what's the difference between

[self.view addSubview:view1];

and

[super.view addSubview:view1];

Thank You!!

Franhu

Upvotes: 4

Views: 1862

Answers (2)

Lily Ballard
Lily Ballard

Reputation: 185831

Unless you've overridden the -view method, there is no practical difference. From a semantic difference, though, saying super.view is an express attempt to avoid invoking a method named -view defined in the current class. Unless you want to express that meaning, you should stay away from the super.whatever construct.

Upvotes: 6

Tim Potter
Tim Potter

Reputation: 2457

Since view is a property, there isn't really much difference when it comes down to it.

Personally I think the self.view is more readable and is the more commonly used idiom as far as I know.

Upvotes: 0

Related Questions