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

Hi! Can you help me please. I try to write float variables,but it doesn't work and i need help. Thanks a lot

sorry,can you help me please

2 Answers

Floats are pretty simply, the way you make them are by doing the class name which is float then the name then define it. Heres an example '''Objective-C

Int main { Float myFloat = 0.5; Float otherFloat = 1.1

Float answer = myFloat + otherFloat;

Return answer;

}

'''

So that's the basics, one of the best web sites in the world is ray wonderlich.com which is first on google, look it up there because theres great articles, besides that practice practice practice becuase you'll use them alot in your developer career.

Hope this helps, Kai.

Tyler Pflueger
Tyler Pflueger
8,089 Points

As Kai Aldag says, you would able to use it his way.

Another way is by using NSNumber to create a float number NSNumber *number = [NSNumber numberWithFloat:4.1234]

Hopefully this is helpful.