I migrated my code to swift 2.3 which resulted in "Extra argument 'error' in call" for the line:
var count:Int = moc.countForFetchRequest(fetchRequest, error: nil)
So, I found to handle it with try catch from: Swift: Extra argument 'error' in call, and put it inside try catch as follows:
var count:Int = 0
do {
count = try moc.countForFetchRequest(fetchRequest)
return count
} catch let error as NSError {
print("Error: \(error.localizedDescription)")
return count
}
Now its showing error on returning count. Error is: "Cannot convert return expression of type 'int' to return type 'NSArray' ". Couldn't figure out the new syntax error. Please help.