Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Homer Denson
2,024 PointsInheritance Compositions question
I'm fairly new to Obj C, and I just want to know when is the best time to use inheritance and compositions? Also when exactly do I use "@property (nonatomic, strong)? when I have a property that belongs to a class? which my be an easy answer.
1 Answer
JEONG EUN KIM
2,270 PointsComposition means consists of many things. Mean Single big object/class consists of many objects in it.
Ex:
@interface Computer { CPU * ptrCpu; Monitor* ptrMonotor; Mouse* ptrMouse; } @end
Only objects are said to be composed not primitive data type like int ,char etc.
Composition set up "has a" relationship. Its represent that Main object own other small small objects. Ex: Computer has a Cpu.
Inheritance set up "is a" relationship. Ex:-Triangle is a shape