Xcode 6.3.2 Swift 1.2 NSIndexpath does not have member 'row'

244 Views Asked by At

I have a class I use to encapsulate data handling - similar to NSFetchedResultsController, but custom to the needs of the app. I'm converting this class to Swift (dual attempts are for illustration, not actual implementation).

@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

And the Objective-C version, which functions as expected:

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

}

Looking at the NSIndexPath header and documentation, for both Swift and Objective-C reveals no property or function named 'row'; so, I'm at a loss.

Note: I have tried both optional and non-optional variations.

The passed NSIndexPath in the sample code is non-optional, which is why I believe this issue is different than the following:

Nor does the method have any outside knowledge at this point for the issue to be similar to this:

At least I don't think so. If this is a duplicate of those, such is life and I do apologize.

Update:

Clean & build - no change.

1

There are 1 best solutions below

0
On BEST ANSWER

You need to import UIKit.

section, row and item are properties of NSIndexPath added by UIKit.

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