Aprove answer
protocol Track {
    title: String
    albumTitle: String
    // other method and properties

class JSONTrack: Track {
    // implementation

class CoreDataTrack: Track {
    // implementation

let tracks = [Track]()


enum TrackEnum {
    case json(JSONTrack)
    case coreData(Track)

More Answer related to the Same Query


class JSONTrack: NSObject {}
class OtherTrack: NSObject {}

enum Track {
    case jsonTrack(JSONTrack)
    case otherTrack(OtherTrack)

    // enum can be handy if you want to do type checking
    // and e.g. present specific data for that type
    var label: String {
        switch self {
        case .jsonTrack:
            return "Json track"
        case .otherTrack:
            return "Other track"

let jsonTrack = JSONTrack()
let otherTrack = OtherTrack()
let tracks: [Track] = [Track.jsonTrack(jsonTrack), Track.otherTrack(otherTrack)]

let labelOfTrack1 = tracks.first!.label
// prints "Json track"

Credit Goes to: stackoverflow.com

Related question with same questions but different answers