With Swift 1.2 (yes, I've not switched over to Xcode 7, which is causing me grief), I have the following table view delegate method:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coreDataSource.numberOfRowsInSection(section)
}
which causes Xcode 6.4 to give the error:
Cannot invoke 'numberOfRowsInSection' with an argument list of type '(Int)'
My CoreDataSource method, bridged from Objective-C, has the following .h declaration:
- (NSUInteger) numberOfRowsInSection: (NSUInteger) section;
If I apply a UInt coercion in my table view delegate method:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coreDataSource.numberOfRowsInSection(UInt(section))
}
Xcode now gives the error:
'UInt' is not convertible to 'Int'
So, it looks to be damed if you do, damed if you don't kind of scenario.
From Apple's docs, they say:
Swift bridges NSUInteger and NSInteger to Int.
Thoughts?
Int
(returnInt(self.coreDataSource…)
) – Stringfellow