Xcode 6.3.2 Swift 1.2 NSIndexpath没有成员' row'

时间:2015-06-25 23:10:02

标签: ios swift nsindexpath

我有一个用于封装数据处理的类 - 类似于NSFetchedResultsController,但是根据应用程序的需要进行自定义。我将此类转换为Swift(双重尝试仅用于说明,而非实际实现)。

@objc class DataHandler: NSObject {

    final func deleteEntryAt(indexPath: NSIndexPath) {
        let entry = entries[indexPath.row]

        let iRow = indexPath.row
        if let row = indexPath.row {

        }
    }
}

enter image description here

Objective-C版本,按预期运行:

- (void)deleteEntryAtIndexPath:(NSIndexPath*)indexPath {
    Entry *entry = self.entries[indexPath.row];

}

查看NSIndexPath标头和文档,对于Swift和Objective-C,都没有显示出名为' row&#39 ;;所以,我不知所措。

注意:我尝试了可选和非可选的变体。

示例代码中传递的NSIndexPath是非可选的,这就是为什么我认为这个问题与以下内容不同:

此方法也不具备任何外部知识,因为该问题与此类似:

至少我不这么认为。如果这是一个副本,那就是生活,我道歉。

更新

清洁&建立 - 没有变化。

1 个答案:

答案 0 :(得分:1)

您需要导入salesRank <- tapply(dat$sales, dat$category, order, decreasing = T) scoreRank <- tapply(dat$score, dat$category, order, decreasing = T) cbind(dat, salesRank = unlist(salesRank), scoreRank= unlist(scoreRank)) ID category sales score salesRank scoreRank A1 227 A 109 21 3 2 A2 131 A 410 24 2 1 A3 131 A 509 1 1 3 B1 123 B 2 61 2 1 B2 545 B 19 5 1 2 C1 234 C 439 328 2 1 C2 654 C 765 41 1 2

UIKitsectionrow是UIKit添加的item的属性。

https://developer.apple.com/library/prerelease/ios//documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/index.html