Version 1.0 of TagTunes.
This commit is contained in:
65
TagTunes/SearchResult.swift
Normal file
65
TagTunes/SearchResult.swift
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// SearchResult.swift
|
||||
// TagTunes
|
||||
//
|
||||
// Created by Kim Wittenburg on 31.08.15.
|
||||
// Copyright © 2015 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
/// Represents an `Album` returned fromm the
|
||||
/// [Search API](https://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html).
|
||||
public class SearchResult: Equatable {
|
||||
|
||||
public let id: iTunesId
|
||||
|
||||
public let name: String
|
||||
|
||||
public let censoredName: String
|
||||
|
||||
public let viewURL: NSURL
|
||||
|
||||
public let artwork: Artwork
|
||||
|
||||
public let trackCount: Int
|
||||
|
||||
public let releaseDate: NSDate
|
||||
|
||||
public let genre: String
|
||||
|
||||
public let artistName: String
|
||||
|
||||
public init(representedAlbum: Album) {
|
||||
id = representedAlbum.id
|
||||
name = representedAlbum.name
|
||||
censoredName = representedAlbum.censoredName
|
||||
viewURL = representedAlbum.viewURL
|
||||
artwork = representedAlbum.artwork
|
||||
trackCount = representedAlbum.trackCount
|
||||
releaseDate = representedAlbum.releaseDate
|
||||
genre = representedAlbum.genre
|
||||
artistName = representedAlbum.artistName
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Album {
|
||||
|
||||
public convenience init(searchResult: SearchResult) {
|
||||
self.init(id: searchResult.id, name: searchResult.name, censoredName: searchResult.censoredName, viewURL: searchResult.viewURL, artwork: searchResult.artwork, trackCount: searchResult.trackCount, releaseDate: searchResult.releaseDate, genre: searchResult.genre, artistName: searchResult.artistName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public func ==(lhs: SearchResult, rhs: SearchResult) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
|
||||
public func ==(lhs: SearchResult, rhs: Album) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
|
||||
public func ==(lhs: Album, rhs: SearchResult) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
Reference in New Issue
Block a user