death7eater
death7eater

Reputation: 1134

iphone development: is it possible to extend more than one viewControllers?

in my app I want to use googleAnalytics. To use it I have to extend GAITrackedViewController but the problem is I already extend GLKViewController because my view has an openGL application. So is it possible to extend the properties of both view controllers?

Upvotes: 1

Views: 1148

Answers (4)

Dima
Dima

Reputation: 8662

it is very bad to extend 2 classes even on languages that allow it, because you can get 2 ways to your "super" and this is a way to many bugs

Upvotes: 0

fguchelaar
fguchelaar

Reputation: 4909

For a similar case, I've simply created a subclass of UIViewController (GLKViewController in your case). That subclass handles the tracking of the view. All "specific" ViewControllers extend that custom UIViewController, instead of the default one.

Then you could, for instance, track the view manually:

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker sendView: NSStringFromClass(self.class)];

Upvotes: 2

Ramy Al Zuhouri
Ramy Al Zuhouri

Reputation: 22006

No, there isn't multiple inheritance in Objective-C. You have write a subclass of GAITrackedViewController and a subclass of GLKViewController separately, and write a controller class that has an instance of these two classes, coordinating them.

Upvotes: 1

toasted_flakes
toasted_flakes

Reputation: 2509

It's not possible, objective-C doesn't support multiple inheritance. You should take a look to this question: Objective-C multiple inheritance

Upvotes: 0

Related Questions