此代码段在Swift 2中运行完美
override func prepare(for segue: UIStoryboardSegue?, sender: Any?) {
if (segue!.identifier == "FeedDetailSeg") {
let viewController:ItemDetail = segue!.destination as! ItemDetail
viewController.DetailItem = collectionItems![self.selectedRow]
if self.cognitoID == collectionItems![self.selectedRow].seller {
viewController.owned = true
}
else {
viewController.owned = false
}
//remove item from untapped
//appDelegate.untapped.removeAtIndex(self.selectedRow)
//collect view info
self.dataStash(collectionItems![self.selectedRow].ID, itemCondition: 2).continueWithBlock({
(task: BFTask!) -> BFTask! in
if (task.error != nil) {
print(task.error!.description)
} else {
print("DynamoDB save succeeded")
}
return nil;
})
}
}
现在在Swift 3中,我得到一个错误
//collect view info
self.dataStash(collectionItems![self.selectedRow].ID, itemCondition: 2).continueWithBlock({
说的是:
无法转换类型'((BFTask !)-> BFTask!'到预期的参数类型'(BFTask?)->是吗?!
这是使用AWS将项目保存到DynamoDB的。
最佳答案
像这样将返回类型更改为Any?
而不是BFTask?
,
//collect view info
self.dataStash(collectionItems![self.selectedRow].ID, itemCondition: 2).continueWithBlock({
(task: BFTask!) -> Any! in
if (task.error != nil) {
print(task.error!.description)
} else {
print("DynamoDB save succeeded")
}
return nil;
})
谢谢:)