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!

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

Christiaan Hendriksen
Christiaan Hendriksen
5,982 Points

Hardcoded label values in Swift/iOS

When I completed the Android Track, every label value was saved in a central 'dictionary' then referenced. To make them easier to update, allow for localisation, etc.

Through the Swift / iOS course every label has been added directly as a property. Is this best practice? Is there a dictionary alternative like Android?

1 Answer

Michael Reining
Michael Reining
10,101 Points

Hi Christiaan,

The best way to do that is via the NSLocalizedString. Just Google that to learn more about it. Apple also has a pretty solid guide on how to get started with localization here:

https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPInternational/Introduction/Introduction.html

I hope that helps,

Mike

PS: Thanks to the awesome resources on Team Treehouse, I launched my first app.

Now you can practice writing Swift code directly on your iPhone :-)

Code! Learn how to program with Swift

https://itunes.apple.com/app/code!-learn-how-to-program/id1032546737?mt=8