Problem: Implicit conversion shortens 64-bit value into a 32-bit value

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Problem: Implicit conversion shortens 64-bit value into a 32-bit value

    Hallo, ich erstell gerade einen Kompass. Habe den folgenden Code in einer anderen App schon einmal benutzt, da hat er fehlerfrei funktioniert. Nun kommt immer die Meldung: Implicit conversion shortens 64-bit value into a 32-bit value. In der Zeile: CGFloat heading = -1.0f * M_PI * newHeading.magneticHeading / 180.0f; tritt der Fehler immer auf.

    Quellcode

    1. #import <UIKit/UIKit.h>
    2. #import <CoreLocation/CoreLocation.h>
    3. #import <QuartzCore/QuartzCore.h>
    4. @interface CompassViewController : UIViewController <CLLocationManagerDelegate>
    5. {
    6. IBOutlet UIImageView *arrow;
    7. CLLocationManager *locManager;
    8. }
    9. @property (retain) CLLocationManager *locManager;
    10. @end
    11. @implementation CompassViewController
    12. @synthesize locManager;
    13. - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
    14. {
    15. NSLog(@"Location manager error: %@", [error description]);
    16. }
    17. - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
    18. {
    19. CGFloat heading = -1.0f * M_PI * newHeading.magneticHeading / 180.0f;
    20. arrow.transform = CGAffineTransformMakeRotation(heading);
    21. }
    22. - (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager
    23. {
    24. return YES;
    25. }
    26. - (void) viewDidLoad
    27. {
    28. self.locManager = [[[CLLocationManager alloc] init] autorelease];
    29. self.locManager.delegate = self;
    30. if (self.locManager.headingAvailable)
    31. [self.locManager startUpdatingHeading];
    32. else
    33. arrow.alpha = 0.0f;
    34. }
    35. @end
    36. int main(int argc, char *argv[])
    37. {
    38. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    39. int retVal = UIApplicationMain(argc, argv, nil, nil);
    40. [pool release];
    41. return retVal;
    42. }
    Alles anzeigen



    Danke für Eure Hilfe.
  • Quellcode

    1. CGFloat heading = -1.0f * (CGFloat)M_PI * (CGFloat)(newHeading.magneticHeading) / 180.0f;
    oder

    Quellcode

    1. CGFloat heading = (CGFloat)(-1.0 * M_PI * newHeading.magneticHeading / 180.0;

    M_PI und magneticHeading sind beides double. Dadurch kommt die Meldung wenn sie implizit auf float konvertiert werden.

    Chris
    Man macht einfach solange irgendwelche Dinge, bis man tot ist.
    Und dann bekommen die anderen Kuchen.