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 Build a Weather App with Swift (Retired) Displaying Our Weather Data Creating the User Interface

Roderick Kar
Roderick Kar
8,456 Points

why 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
Thomas Nilsen
14,957 Points

Because 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 :)

Hi,

I'm getting the following error here:

"Could not find member "None""

application.setStatusBarHidden(TRUE, withAnimation: .None)

Could you please help resolve? Thanks!

Make sure you type the word true in small letters.

Eric Whittaker
Eric Whittaker
2,974 Points

It will keep trying to capitalize it until you type the letters for "true" and hit the spacebar. Swift can be sneaky....

Prem Kumar: THANK YOU! Came here for that question :)

I 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
Roderick Kar
8,456 Points

Hi Thomas,

That's very helpful. Thanks!

Regards,

Roderick

Bradley Allen
Bradley Allen
5,224 Points

Ok, so what is special about "TRUE"?

Bobbie Chan
PLUS
Bobbie Chan
Courses Plus Student 2,806 Points

Yes, why capital letter TRUE doesn't work? I switch to true and .None works immediately. What's the issue with that?

Bradley Allen
Bradley Allen
5,224 Points

Thanks Gabriel!

I realize now I broke rule #1 about asking questions: check StackOverflow first.