NSUInteger和NSInteger联系Swift

Chr*_*nce 3 objective-c swift xcode6 ios8.4

使用Swift 1.2(是的,我没有切换到Xcode 7,这让我感到悲伤),我有以下表格视图委托方法:

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.coreDataSource.numberOfRowsInSection(section)
}
Run Code Online (Sandbox Code Playgroud)

这导致Xcode 6.4给出错误:

无法使用类型'(Int)'的参数列表调用'numberOfRowsInSection'

从Objective-C桥接的我的CoreDataSource方法具有以下.h声明:

- (NSUInteger) numberOfRowsInSection: (NSUInteger) section;
Run Code Online (Sandbox Code Playgroud)

如果我在表视图委托方法中应用UInt强制:

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.coreDataSource.numberOfRowsInSection(UInt(section))
}
Run Code Online (Sandbox Code Playgroud)

Xcode现在给出错误:

'UInt'不能转换为'Int'

所以,如果你这样做,它看起来会被淹没,如果你没有这种情况,它会被淹没.

Apple的文档中,他们说:

Swift将NSUInteger和NSInteger连接到Int.

思考?

Aar*_*ger 8

将整个return语句换行Int(返回Int(self.coreDataSource…)).