我有点困惑。我在Objective-C中有这个代码,我需要在swift中进行转换(得到相同的结果)。例如:For循环等效Swift 3
NSArray *cells = [self.someTableView visibleCells];
for (SomeTableViewCellClass *someCell in cells){
// some coding
}
我已经试过这样,但它抛出,说是从来没有使用someCell一个错误,请考虑将其删除:
for someCell in cells { // in this line
let comeCell = SomeTableViewCellClass
// some coding
}
但是,如果我不喜欢这样,它说,不能从一个值转换到另一个:
for someCell in cells as SomeTableViewCellClass { // in this line
// some coding
}
我知道这里是关于这个问题的一些职位,但像我读他们,他们是有点不同的,可以与我自己的代码NR来解决。 2。我在Objective-C文件中有很多这样的循环,所以如果有人可以帮助我并回答是否有任何等价物,我将不胜感激!
这个问题的答案实际上是遍布互联网......这是一个链接到苹果文档,所以你不必自己google:https://developer.apple.com/library/content/documentation/Swift/概念/ Swift_Programming_Language/ControlFlow.html – katzenhut