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 trialRoderick Kar
8,456 Pointswhy does none in "application.setStatusBarHidden(true, withAnimation: .None)" need to be ".None"?
I got an error while following the video and took a while to realize I had used "none" instead of ".None". I then realized there's another similar usage in one of the previous videos in the same course. I am new to both Swift and Objective-C, just wondering why and when the prefix . is needed. Thanks.
7 Answers
Thomas Nilsen
14,957 PointsBecause if you look at the implementation of that function, it looks like this:
func setStatusBarHidden(_ hidden: Bool,
withAnimation animation: UIStatusBarAnimation)
It takes a bool, and an enum. If you dig deeper in the documentation, the enum looks like this:
enum UIStatusBarAnimation : Int {
case None
case Fade
case Slide
}
There are two ways to access an enum.
1.way:
UIStatusBarAnimation.None
2.way (called enum type inferred)
.None
Hope this was helpful :)
Mukul Gupta
8,760 PointsHi,
I'm getting the following error here:
"Could not find member "None""
application.setStatusBarHidden(TRUE, withAnimation: .None)
Could you please help resolve? Thanks!
Prem Kumar
4,270 PointsMake sure you type the word true in small letters.
Eric Whittaker
2,974 PointsIt will keep trying to capitalize it until you type the letters for "true" and hit the spacebar. Swift can be sneaky....
Greg Mazzeo
2,409 PointsPrem Kumar: THANK YOU! Came here for that question :)
Joshua Wink
16,042 PointsI came here for that question also and the answer helped. But now I am wondering why does true have to be lower case? I want to understand the difference because might have taken me forever to troubleshoot on a project that doesn't have a board dedicated to it.
Roderick Kar
8,456 PointsHi Thomas,
That's very helpful. Thanks!
Regards,
Roderick
Bradley Allen
5,224 PointsOk, so what is special about "TRUE"?
Bobbie Chan
Courses Plus Student 2,806 PointsYes, why capital letter TRUE doesn't work? I switch to true and .None works immediately. What's the issue with that?
Gabriel Ruiz
1,505 PointsBradley Allen
5,224 PointsThanks Gabriel!
I realize now I broke rule #1 about asking questions: check StackOverflow first.