Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions OwnRadio/OwnRadio/Downloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Downloader {
} else {
//если этот трек не еще не загружен - загружаем трек
//используется замыкание для сохранения загруженного трека в файл и информации о треке в бд
URLSession.shared.downloadTask(with: audioUrl, completionHandler: { (location, response, error) -> Void in
let downloadRequest = URLSession.shared.downloadTask(with: audioUrl, completionHandler: { (location, response, error) -> Void in
guard let location = location, error == nil else { return }
do {
let file = NSData(contentsOf: location)
Expand Down Expand Up @@ -74,7 +74,11 @@ class Downloader {
} catch let error as NSError {
print(error.localizedDescription)
}
}).resume()
})
self.taskQueue?.addOperation {
downloadRequest.resume()
}

}
}
}
Expand Down Expand Up @@ -116,10 +120,7 @@ class Downloader {
// задаем единственную операцию в один момент времени
self.taskQueue?.maxConcurrentOperationCount = 1
for _ in 0..<3 {

self.taskQueue?.addOperation { [unowned self] in
self.load(complition: complition)
}
self.load(complition: complition)
}
}

Expand Down
2 changes: 1 addition & 1 deletion OwnRadio/OwnRadio/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>2017.01.30</string>
<key>CFBundleVersion</key>
<string>3231</string>
<string>3236</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down