Reputation: 489
I have a class that has a few init methods and, after adding a new variable and therefore a new init, I began getting the following error only when I'm compiling to run the unit tests (I can compile and run my app without getting that error):
Overloads for 'SearchedLocation' exist with these partially matching parameter lists: (invocation: NSInvocation?), (selector: Selector), ()
My class is:
class SearchedLocation : NSObject, MKAnnotation {
let coordinate: CLLocationCoordinate2D
let address : String?
let neighborhood : String?
let city : String
let fullAddress : String?
let name : String?
// ....
init(coordinate: CLLocationCoordinate2D, address: String, neighborhood: String, city: String, fullAddress: String) {
self.coordinate = coordinate
self.address = address
self.neighborhood = neighborhood
self.city = city
self.fullAddress = fullAddress
self.name = ""
}
init(coordinate: CLLocationCoordinate2D, address: String, neighborhood: String, city: String, fullAddress: String, name: String?) {
self.coordinate = coordinate
self.address = address
self.neighborhood = neighborhood
self.city = city
self.fullAddress = fullAddress
if name != nil && !name!.isEmpty {
if self.fullAddress!.contains(name!) {
self.name = ""
} else {
self.name = name!
}
} else {
self.name = ""
}
}
And this is where I'm getting the error:
let place = SearchedLocation(coordinate: (placemark?.coordinate)!, address: address, neighborhood: placemark!.subLocality!, city: placemark!.locality!, fullAddress: fullAddress)
That code was working just fine (even when running the tests) until I added the last init method to the class.. And now even when I comment it I keep getting that error.
Anyone has any idea of what it is about?
Upvotes: 3
Views: 198
Reputation: 489
After undoing my changes I realized that I had created a test class named "SearchedLocation", just as my class. So that's why I was getting that error only when compiling to run the tests.
Stupid error :(
Upvotes: 3