Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

AR Ehsan
AR Ehsan
7,912 Points

RWDropdownMenu

Can someone convert this repository called RWDropdownMenu(https://github.com/eternityz/RWDropdownMenu) It is in objective-c. So far I have installed it through cocoapods and have everything setup. The only thing I don't know how to do, is USE IT. Please help

3 Answers

Keli'i Martin
Keli'i Martin
8,227 Points

You don't need to convert it to Swift in order to use it in your Swift project. You would need to create a bridging header, though. Check out this link for some detailed instructions about how exactly to add one to your project.

As far as using it, the author didn't really provide very helpful instructions. Your best bet is to check out the demo project that comes with the library and see how the author uses it there. Of course, the demo app is also in Objective-C, so you would need to be able to translate what he's done in his demo to Swift. It's tricky, but not impossible.

I've uploaded a really quickie sample of using that menu in a Swift project to my Github account. It doesn't look exactly the same as the demo that comes with the library, but it should give you a place to start.

Hope this helps!

AR Ehsan
AR Ehsan
7,912 Points

Thanks so much!

Keli'i Martin
Keli'i Martin
8,227 Points

No problem! You know, ever since posting up that sample, I've started actually trying to create a Swift version of the library as an exercise. I'll post it up on Github at some point, if I can actually get it to work. :)

AR Ehsan
AR Ehsan
7,912 Points

Great. Create a nice animation library with swift. that would be cool

AR Ehsan
AR Ehsan
7,912 Points

Sorry but I have another question, how can I present a view controller when a dropdownmenu is selected? I have tried so many times adding performSegueWithIdentifier("Show About Screen", sender: self) but I keep getting an error :( any help? Keli'i Martin

Keli'i Martin
Keli'i Martin
8,227 Points

Honestly, I'm not sure. I've been trying to figure out this library myself. There's a lot going on that I'm not entirely familiar with. From what I can gather, the menu items are a part of a UICollectionView. RWDropdownMenu implements the delegate and datasource protocols, which is what you would normally need to do know which cell you are clicking. But I don't think you need to worry about that.

The RWDropdownMenuItem allows you to pass in a completion handler when you create them. My guess is that this is how you will cause something to happen when you select an option. Beyond that, I'm not sure. I'll take another look at it and try playing around with it some.

AR Ehsan
AR Ehsan
7,912 Points

Ok I hope we both figure it out :)