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

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

Swift 1.2 and Xcode 6.3 beta

Hey iOS students. Apple just released Xcode 6.3 beta which includes the latest iteration of the Swift language.

There are quite a few changes to the language and you can read up on the official Swift blog.

I'm including a very important quote from the post below because it will affect anyone who takes existing content and uses Xcode 6.3 beta.

Swift 1.2 is a major step forward for both the language and the tools. It does include some source-incompatible changes that require updates to your code, so Xcode 6.3 includes a migrator to help automate the process. To begin the migration, click the Edit menu, then choose Convert > To Swift 1.2...

That being said, I won't be updating existing courses to use Xcode 6.3 beta since there is no guarantee that Swift won't change again soon. That would also stop the production of any new Swift or Objective-C content.

If you have any questions, please feel free to ask me or any of our excellent moderators. In the meantime, I'm going to go download Xcode 6.3 and get started :)

I read the Swift release notes for Xcode 6.3, what is the most significant change and/or addition in your opinion?

Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

In my opinion, it's combined if lets followed by the as! operator.

4 Answers

Getting the beta when I get home from work, really good to know the Swift developers are continuing to grow the language even though it's still pretty much new off the shelf.

Do we have any WatchKit courses coming out? Or is there something on the blog?

Mike

Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

No plans yet. Once Apple releases a stable build, I will look into it. But it's more complicated than it looks so will have to release some prerequisite courses before I can get to actual watch kit apps

Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

No plans yet. Once Apple releases a stable build, I will look into it. But it's more complicated than it looks so will have to release some prerequisite courses before I can get to actual watch kit apps

That's what I thought! I'm super noob with iOS, but slowly understanding the language of Swift. Hopefully when they release this year, we will have a good understanding of the device and Watchkit.

I'm not a fan of Wearables, but interested in how we can use the technology to improve our lives / if it will.

Here's to Swift 1.2! I hope my weather app does not brake to bad lol.

Update: I had to add a few "as!" to it. But it works!

That's an interesting place to put a bang, are you downcasting something?

I'm downloading the weather data after I grab the users location.

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
        CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: {(placemarks, error)->Void in

            let pm = placemarks[0] as! CLPlacemark
            self.displayLocationInfo(pm)
            })

        if (locationFixAchieved == false) {
            locationFixAchieved = true
            var locationArray = locations as NSArray
            var locationObj = locationArray.lastObject as! CLLocation
            var coord = locationObj.coordinate
            self.userLatitude = coord.latitude
            self.userLongitude = coord.longitude

            getCurrentWeatherData() //getting the weather data
        }
    }
Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

Chris Upjohn,

The as operator implicitly unwraps an optional when down casting. This has the potential to cause crashes if the optional being cast is nil. To make it more obvious what as is doing, Swift now implements it as as!. Behavior is the same but when you're reading code you know that you're force unwrapping by using as!.