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 Enhance a Weather App with Table Views Upgrading Stormy Custom Background Views

Marcelo Farjalla
Marcelo Farjalla
3,241 Points

Why a Cocoa Touch Class and now a Swift source file?

I was just wondering why we chose a Cocoa Touch class file and not a new Swift source file when we decided to create the new TableView file for this exercise. I'd like to understand the reasoning so I can distinguish when to use which in the future. Thanks in advance.

The difference between the two files types lies in the boilerplate code each file type inherits. A cocoa touch class files imports UIKit, which provides the classes, properties and methods associated with typical UI or storyboard or view controllers. A standard swift file imports the Foundation API.

The difference between the two files types lies in the boilerplate code each file type inherits. A cocoa touch class files imports UIKit, which provides the classes, properties and methods associated with typical UI or storyboard or view controllers. A standard swift file imports the Foundation API.