Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics (Retired) Pointers and Memory Structs

sorry i really don't get this video can someone please teach me what's struct about?

can someone please explain to me what struct is about? its so confusing.

1 Answer

Jordan Aldujaili
Jordan Aldujaili
5,852 Points

Ok, so this is how I understand what a struct is, if I am wrong, I hope someone corrects me.

Here is a metaphor: Think of a way to define a fruit. It is sweet and there are seeds. Now you have two attributes to define the fruit instead of the just normal way of just being a string or an int.

typedef struct{
 string seeds;
 string sweetness;
} Fruit;

And now, instead of it being string *banana, its Fruit banana, which now you have access to the seeds and sweetness. Hope that makes sense