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 Basic Data Types and Variables Numerical Data Types: ints, floats and doubles

Explaining Different Token Naming Conventions

Hi all, I'm going through Gabe's Objective C class, and he's starting to use different tokens like %i and %f. At first I thought he was just using letters that corresponded with the token data type, like %i for int etc., but then I noticed that he was getting errors in his code when he changed a data type from int to float. Can someone explain to me more about the different token naming conventions? Thanks.

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hey there,

You're pretty much correct in that each one is specific to the type. For example %i is for an Integer... %f is for a float... %s is for a string... etc. So if he had %i and then changed the type to a float, an error would be thrown, because the format specifier is expecting an integer.

You can see the different format specifiers on the Apple Dev site.

Hope that help to clear it up for you. :)


I was thinking that a float value is still mathematically an integer value, but in code they're very different! :D