I am currently working on an implementation of SoundCloud for a 3rd party iOS app, and as there is no SDK anymore I am doing all my calls via Alamofire.
This is what SC expects you to send in your body params:
{ "playlist":
{"tracks":[
{"id":"__"},
{"id":"__"},
{"id":"__"}]
}
}
I hand over the current playlist where the song should be added in the playlist object to extract all the ids from tracks that are part of it atm - as SC expects you so send all the old track ids + your new one in a .PUT call
This is what the ID dance looks at the moment:
var allTracks = [Int]() //SC track id comes in as an Int
allTracks.append(trackId) //trackId is the new track
for track in playlist.tracks {
var I = track.id
allTracks.append(I)
}
var myparams = Dictionary<String,AnyObject>() //my Alamofire body-params
var myTracks = [Dictionary<String,AnyObject>]()
for id in allTracks {
var D = ["id":id]
myTracks.append(D)
}
myparams["playlist"] = ["tracks":myTracks]
As I am still fairly new to Swift/iOS Development I was looking for a more elegant way than to just throw stuff around 3x and end up basically appending it the way it came in.