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

iOS Objective-C Basics (Retired) Fundamentals of C Variables

Need help in variables

I really don't get it. Can you help me please!

Damien Watson
Damien Watson
27,419 Points

Hi Roger, what specifically don't you understand about variables?

  • What a variable is?
  • How to use one or why?
  • When do I use 'int' vs 'char' etc.

1 Answer

Hi Roger, I'll do my best to help you out.

Think of a variable as a box where you will store a value (empty being a valid value for it.)

You use variables to store data and use it around your application. Using variables can help you save computing power as you can avoid having to recalculate values when you're going to use it several times. It can also be used to change the value of Labels, Images and other components in your User Interface.

There are different types of values that your variable can store. The type you choose for your variable will depend on what you want it to store. For example, the number 2 can be stored as an Int if you're going to be using it for mathematical operations, but can be stored as "2" in the form of a string if you're primarily going to use it as text. You can usually convert numbers stored as string into number formats (such as float or decimal.)

Apple has great documentation on the different kind of variable types and what they can be used for in case you want to dive further into it.

I hope this helps, and feel free to ask follow up questions!

Thanks for your support!