Foundation.Data issue

So the below code was working no issues, but has started to play up.
The error I am getting is Cannot convert value of type 'Foundation.Data' to specified type 'vscroll.Data' & Cannot convert value of type 'vscroll.Data' to expected argument type 'Foundation.Data'

 func getPodCastPlayerNP(completion: @escaping (NowPlayingData) -> ()) {
       // Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { (timer) in
          let songdata = "{\"id\": \"1\",\"song\": \"\(MusicPlayer.song)\",\"artist\": \"\(MusicPlayer.artist)\", \"cover\": \"\(MusicPlayer.cover)\"}"
        let data: Data = songdata.data(using: .utf8)!
          
          let podcast = try! JSONDecoder().decode(NowPlayingData.self, from: data!)
        
                         //print(data!)
                        // let episode = podcast.programs
                        DispatchQueue.main.async{
                            // The array is stored under programs now
                          //print(podcast)
                          completion(podcast)
                        }
         // }
      }

the two lines are

let data: Data = songdata.data(using: .utf8)!
let podcast = try! JSONDecoder().decode(NowPlayingData.self, from: data!)

Would anyone have a solution to fix this please. It was working up to an hour ago.

Seem the solution was really easy Just put Foundation.Data instead of Data

It seems you have imported a module called vscroll which defines its own Data. And the Data defined in vscroll (vscroll.Data) gets mixed up with Data from Foundation (Foundation.Data).

Usually you just disambiguate it like you just did.

Terms of Service

Privacy Policy

Cookie Policy