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 Swift 2.0 Enumerations and Optionals Introduction to Enumerations Enum Methods

nil target and action? [Resolved]

I managed to get through task 1 of 2 with this code added to "enums.swift":

let done = Button.Done("Done")

..but I have really no idea what type of code is needed for task 2 of 2...?

Was there a swift course that described in detail all about target and action?

A quick google search turned up this old Treehouse blog post (but I think it's pre-Swift):

http://blog.teamtreehouse.com/ios-design-patterns-target-action-part-1

I remember there was a "target-Action link in the Teacher's notes for the Build a Simple iPhone App with Swift course (but of course who ever bothers to click through links in Teacher's Notes "whoops!" ):

https://teamtreehouse.com/library/build-a-simple-iphone-app-with-swift/views-and-view-controllers/view-controllers-and-ibaction


I did find this stackoverflow thread that might be related (shows assigning both target and action):

http://stackoverflow.com/questions/24641350/how-to-set-the-action-for-a-uibarbuttonitem-in-swift

It says the question asked in that thread has to do with this other stackoverflow thread which talks about selectors:

http://stackoverflow.com/questions/24007650/selector-in-swift


Maybe the answer can be found by understanding the answers given in those two stackoverflow threads,

but I certainly didn't see how its related to the 'func color()' code in the "Methods on Enumerations" video:

https://teamtreehouse.com/library/swift-20-enumerations-and-optionals/introduction-to-enumerations/methods-on-enumerations

Also (just for cross reference) there is a related forum thread about that 'func color()' code (which is in the 'SwiftEnumsOptionals-S2' download for the course):

https://teamtreehouse.com/community/i-dont-understand-let-redvalue-let-greenvalue-here


Also found:

There seems to be some documentation to the actual (real) UIStatusBarStyle enumerations ('BlackOpaque', 'BlackTranslucent', 'Default', and 'LightContent') here:

https://developer.xamarin.com/api/type/UIKit.UIStatusBarStyle/

1 Answer

I found this forum thread helpful in answering this question:

https://teamtreehouse.com/community/task-2-of-2-assigning-done-button-shows-compiler-errors