-코스는 움직이는 물체의 방향을 반환합니다. 따라서 사용자의 현재 위치에서 -Course를 호출합니다. 위치에서 다른 위치로의 방향을 제공하지 않습니다. 따라서 NYC가 움직이지 않으면 항상 -1을 반환합니다.
나침반 제목을 찾으려면 움직여야합니다.
#define RAD_TO_DEG(r) ((r) * (180 / M_PI))
...
CLLocationCoordinate2D coord1 = currentLocation.coordinate;
CLLocationCoordinate2D coord2 = distLoc.coordinate;
CLLocationDegrees deltaLong = coord2.longitude - coord1.longitude;
CLLocationDegrees yComponent = sin(deltaLong) * cos(coord2.latitude);
CLLocationDegrees xComponent = (cos(coord1.latitude) * sin(coord2.latitude)) - (sin(coord1.latitude) * cos(coord2.latitude) * cos(deltaLong));
CLLocationDegrees radians = atan2(yComponent, xComponent);
CLLocationDegrees degrees = RAD_TO_DEG(radians) + 360;
CLLocationDirection heading = fmod(degrees, 360);