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

Please explain structs for me!

I don't really get the concept of structs. What's the point of having them? We made a whole bunch of variables, but didn't really do anything.

1 Answer

Hi Tristan,

A struct basically is a way to tie a set of related data together. for instance if I wanted a person struct I could have a char for name, an int for age and a char for job. I like to compare to compare them to classes in objective-c because they hold certain properties (or primitives because C is not object oriented) and these properties normally relevant to each other. a real world example is x and y coordinates are part of a struct, both x and y are relevant to each other so we decide to put them together in a struct.

for more info it's definitely worth googling,

Happy hacking, Kai.

Thanks Kai

No problem :)