0
我有舊的Xcode 7.3 Swift 2代碼。我需要將這兩個for循環更改爲新的swift 3 for循環語法。將舊的C for循環更改爲新的Swift循環
fileprivate func collapseSubItemsAtIndex(_ index : Int) {
var indexPaths = [IndexPath]()
let parent = self.findParent(index)
checkCurrentLanguage()
if lang.isEqual(to: "en")
{
//For loop 1
for (var i = index + 1; i <= index + self.engsubItems[parent].count; i += 1){
indexPaths.append(IndexPath(row: i, section: 0))
}
self.engtableview.deleteRows(at: indexPaths, with: UITableViewRowAnimation.fade)
self.engtotal -= self.engsubItems[parent].count
}
else{
//For loop 2
for (var i = index + 1; i <= index + self.subItems[parent].count; i += 1){
indexPaths.append(IndexPath(row: i, section: 0))
}
self.tableView.deleteRows(at: indexPaths, with: UITableViewRowAnimation.fade)
self.total -= self.subItems[parent].count
}
}
爲什麼就不能'郎== 「恩」'? – Sulthan
@Sulthan我剛剛收到這段代碼,他們需要將它全部更新到swift 3.有很多編碼錯誤,我仍然沒有修復或改進。 –