Closed huangboju closed 8 years ago
Hello,
try something like that
func upload() {
if originalImages.isEmpty {
showAppFailureMessage("...")
return
}
navigationItem.showTitleView(".")
let uploadGroup = Async.Group()
urls = Array(count: originalImages.count, repeatedValue: "")
for (i, image) in originalImages.enumerate() {
if let image = image {
if let imageData = UIImageJPEGRepresentation(image, 0.6) {
uploadGroup.enter()
Http.uploadToCloud("oss", filename: "...", data: imageData, controller: self; success: { [weak self] (urlSuffix) in
uploadGroup.leave()
let imageUrl = "(urlSuffix)"
self?urls[i] = imageUrl
}, failure: { [weak self] in
self?.showAppFailureMessage("...")
})
}
}
}
uploadGroup.main {
self.navigationItem.hideTitleView()
self.projection
}
}
You're not right,
func upload() {
if originalImages.isEmpty {
showAppFailureMessage("...")
return
}
navigationItem.showTitleView(".")
let uploadGroup = Async.Group()
urls = Array(count: originalImages.count, repeatedValue: "")
for (i, image) in originalImages.enumerate() {
if let image = image {
if let imageData = UIImageJPEGRepresentation(image, 0.6) {
uploadGroup.enter()
// 1
Http.uploadToCloud("oss", filename: "...", data: imageData, controller: self; success: { [weak self] (urlSuffix) in
// 3 I want to here is step 2
uploadGroup.leave()
let imageUrl = "(urlSuffix)"
self?urls[i] = imageUrl
}, failure: { [weak self] in
self?.showAppFailureMessage("...")
})
}
}
}
uploadGroup.main {
// 2 I want to here is step 3
self.navigationItem.hideTitleView()
self.projection
}
}