0

Possible Duplicate:
Objective-C multiple inheritance

In my iPhone app I want to use googleAnalytics but the thing is I Have to inherit from GAITrackedViewController which is provided by Google. The problem is I already extend GLKViewController and objective-c does not allow multiple inheritance. some topics suggest to use protocols. I have no idea about them I have never used them before but I think it is too late because I already designed and implemented my project.What can I do? is there any example which solves that kind of a problem?

Community
  • 1
  • 1
death7eater
  • 1,094
  • 2
  • 14
  • 35

2 Answers2

1

Multiple inheritance is rarely a good idea.

implement multiple protocols. read Objective-C Introduction about protocols, They are similar to java interfaces.

If that does not work, because these two classes would not provide a protocol, you still could use aggreation: Define two members, one for glkVieController, the other for gaiTrackedViewController

AlexWien
  • 28,470
  • 6
  • 53
  • 83
1

Objective C does not support multiple inheritance. But by using Composition, Protocols and Message Forwarding you will achieve the same result.

You should refer to apple doc for Multiple Inheritance and Message Forwarding on this link-AppleDoc

For Composition check this link

For Protocols in Objective C check this link Protocol in Objective C

Satish Azad
  • 2,302
  • 1
  • 16
  • 35