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 Simple iPhone App with Swift 2.0 Improving Our User Interface Adding a Pop of Color

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

Is there any similarity between @IBAction and decorators in Python?

Just trying to connect the dots a bit. Is there any connection between @IBAction in Swift and decorators in Python? They both use the @ symbol, and seem to be like a kind of wrapper for a thing.

1 Answer

Nathan Tallack
Nathan Tallack
22,159 Points

Not really. And there is plenty of potential of that confusion across languages. Especially when you are working with them all at the same time.

In XCode the compiler interprets the @IBAction as a way to reference your storyboard code. One way to see this is to show your assistant editor (that is when you get two editors open at once) and have your view controller in one and your storyboard source in the other (right click on your storyboard and choose open as source which opens the XML).

With those two windows open you will see if you highlight your IBAction the corresponding <connections> tag that it refrences. That is what is created when you make your action.

I hope this helps clear this particular issue up. Oh, and btw: Have fun with your storyboard source. It is very eye opening to understand the code behind the GUI of Xcode. Makes you really appreciate what a wonderful IDE it is. :)

Nathan Tallack
Nathan Tallack
22,159 Points

So you can think of it like this.

IOS/OSX are the operating systems that your apps will run on. OSX for desktops/laptops and IOS for iPads/iPhones/iPods. Why these operating systems matter are because of the "frameworks" that have been built for them.

A "framework" is source code that someone has already written that you can build upon. Think of your laptop/desktop computer. If you had to write the code for how a window works, that is how it resizes, how it snaps to the top of the screen, how it minimizes, how it overlaps other windows, etc, that would be a lot of code to write before you could even work out what goes in it. But all that work has been done for you. Cocoa, the framework for OSX, has code that you would use when you are writing your apps.

Now we get to Xcode. Amongst many other things, Xcode is very much aware of the frameworks you will want to build upon to make your app. If you were writing an IOS app for an iPhone, Xcode knows how to read the framework code for how a screen is laid out and gives you lots of easy to use interfaces for working with that code.

Finally Swift or Objective-C. These are the languages that all of these frameworks (that already written code) was written in, and it is the language that you will write your code in to build upon those frameworks. Xcode understands this language very well and can help give you hints and guides and some automation when you are trying to write and modify code.

So, there you have it. Here on TT they have courses that teach you the language so that you can understand those frameworks when you start working with them, and so that you can build upon them with your own applications. They also expose you to the IDE's (Xcode is an IDE) so that you can learn how they can help you writing your code.

Strictly speaking, you could do all your work at a command line with a text editor and still write a full app. But it would take you MUCH MUCH longer, and you would have to be quite an expert to do it.

I hope this helps you understand a little more. If only enough for you to think of more questions to ask.

If you have more feel free to ask them. We are all on here together to learn, and I am very sure plenty of others are just as happy to help you out as I am. :)