Advertisement
matzl

Untitled

Feb 8th, 2023
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.37 KB | None | 0 0
  1. import Foundation
  2.  
  3. struct SongData {
  4.     let name: String
  5. }
  6.  
  7. enum SongQueueContainer {
  8.     case manuallyAdded
  9.     case currentTrackList
  10.     case similarTracks
  11.     case unfamiliarTracks
  12.     case familiarTracks
  13. }
  14.  
  15. class SongQueue {
  16.     static let shared = SongQueue()
  17.    
  18.     // Containers of the song queue.
  19.     var manuallyAddedContainer: [SongData] = []
  20.     var currentTrackListContainer: [SongData] = []
  21.     var similarTracksContainer: [SongData] = []
  22.     var unfamiliarTracksContainer: [SongData] = []
  23.     var familiarTracksContainer: [SongData] = []
  24.    
  25.     func addSongs(newSongs: [SongData], queueContainer: SongQueueContainer) {
  26.         var temp = newSongs
  27.        
  28.         // mach mit temp was du willst
  29.         temp.remove(at: 1)
  30.  
  31.         switch queueContainer {
  32.             case .manuallyAdded: manuallyAddedContainer = temp
  33.             case .currentTrackList: currentTrackListContainer = temp
  34.             case .similarTracks: similarTracksContainer = temp
  35.             case .unfamiliarTracks: unfamiliarTracksContainer = temp
  36.             case .familiarTracks: familiarTracksContainer = temp
  37.         }
  38.     }
  39. }
  40.  
  41. print(SongQueue.shared.manuallyAddedContainer)
  42. SongQueue.shared.addSongs(newSongs: [.init(name: "Enter the Sandman"), .init(name: "Guten Abend, gute Nacht")], queueContainer: .manuallyAdded)
  43. print(SongQueue.shared.manuallyAddedContainer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement