0

I am currently trying to make a music app using swift. This is my first app (not counting a couple tutorial things). I've been looking at some sample code, including Apple's addMusic example, and I have had issues with the following translation of the objective c code into swift:

class ViewController: UIViewController <MPMediaPickerControllerDelegate> {

I get the error "Cannot specialize non-generic type 'UIViewController'. Is there a way to do this that I am missing or will I need to define a separate class to be my picker delegate?

The addMusic code I was looking at is here.

Neeku
  • 3,646
  • 8
  • 33
  • 43
EthanMN
  • 23
  • 1
  • https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html – Kreiri Aug 07 '14 at 16:19

1 Answers1

5

unlike in objective-c, the subclasses and delegates are structured the same as each other with none of the "<>" around them. For example:

class ViewController: UIViewController, MPMediaPickerControllerDelegate, UITableViewDelegate, CustomClassDelegate

You can continually add to the list as you go along, though only one of them can be the superclass (the rest must be delegates or similar) as a class cannot be the subclass of two different parent classes at the same time.

Hope that helps.

Jack Chorley
  • 2,309
  • 26
  • 28