Search code examples
swiftxcodeswift3nsindexpath

swift 3 equivalent for indexAtPosition, urlRequest.url!.isEqual


Hi i am getting following errors while upgrading from swift 2.2 to swift 3

Argument labels '(atPosition:)' do not match any available overloads"

Below are the following code in swift 2.2.could you guys help me out.

private func getIndexInTheLastSection(indexPath: NSIndexPath) -> Int? {
        let index = indexPath.indexAtPosition(indexPath.length - 1)
        if index == NSNotFound {
            return nil
        }
        return index
    }

////////////////


Solution

  • For isEqual error with URL use == instead of isEqual to compare.

    if urlRequest.URL! == strongSelf.request?.urlRequest?.URL {
    

    For error Argument labels '(atPosition:)'

    indexPath.index(atPosition: (indexPath as NSIndexPath).length - 1)