问题
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?
回答1:
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)];
回答2:
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.
回答3:
It's not possible, objective-C doesn't support multiple inheritance. You should take a look to this question: Objective-C multiple inheritance
回答4:
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
来源:https://stackoverflow.com/questions/14216312/iphone-development-is-it-possible-to-extend-more-than-one-viewcontrollers