有一个应用程序可以成功找到您的 GPS 位置,但我需要能够将该 GPS 与 GPS 位置列表进行比较,如果两者相同,那么您将获得奖励。
我以为我有它的工作,但似乎没有。
我将“newLocation”作为您所在的位置,我认为问题在于我需要能够分离 newLocation 的长数据和纬度数据。
到目前为止,我试过这个:
NSString *latitudeVar = [[NSString alloc] initWithFormat:@"%g°", newLocation.coordinate.latitude];
NSString *longitudeVar = [[NSString alloc] initWithFormat:@"%g°", newLocation.coordinate.longitude];
GPS位置列表示例:
location:(CLLocation*)newLocation;
CLLocationCoordinate2D bonusOne;
bonusOne.latitude = 37.331689;
bonusOne.longitude = -122.030731;
进而
if (latitudeVar == bonusOne.latitude && longitudeVar == bonusOne.longitude) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"infinite loop firday" message:@"infloop" delegate:nil cancelButtonTitle:@"Stinky" otherButtonTitles:nil ];
[alert show];
[alert release];
}
这会出现错误“二进制的无效操作数 == 具有支撑 NSstring 和 CLlocationDegrees”
有什么想法吗?