views:

60

answers:

3

I am going crazy - these 2 strings are identical but the code comes back as them being different!:

NSLog(@"nearbyAirport %@", nearbyAirport.geocode);
NSLog(@"airportToFind %@", airportToFind.geocode);

//Try and match geocodes.  If they are the same then airport is valid
if ([[airportToFind geocode] isEqualToString:[nearbyAirport geocode]])
{
return YES;
}

2010-10-29 15:10:59.808 Name[10658:207] nearbyAirport 6296598
2010-10-29 15:11:00.235 Name[10658:207] airportToFind 6296598
+2  A: 

Add quotes around the strings themselves to make sure there aren't spaces. I don't know anything about geocodes, are they always a number? Could you convert them to NSNumber and do an integer compare?

Michael Kernahan
+1 adding quotes around the strings in NSLog is a great debugging tactic to remember
David Gelhar
+1  A: 

Not sure why that wouldn't work. Since they're numbers, maybe try and convert the string to integers and compare those two?

if ([[airportToFind geocode] intValue] == [[nearbyAirport geocode] intValue]) {
     return YES;
     NSLog(@"Success!");
}
Canada Dev
+2  A: 

What is the type of [airportToFind geocode]?

Does it implement isEqualToString:?

David Gelhar
Great catch... is it actually a NSString.
Michael Kernahan