Iphone CLLocationManager didUpdateToLocation,将值带到NSString以在其他地方使用!
在此函数之外使用NSLog(@“%@”,longi)会使我的应用程序崩溃。。。。如何在didUpdateToLocation函数之外使用此NSLog?就像在iAction函数中一样 这个例子效果很好!但是如何在这个之外使用这个nslog呢Iphone CLLocationManager didUpdateToLocation,将值带到NSString以在其他地方使用!,iphone,cocoa-touch,cllocationmanager,Iphone,Cocoa Touch,Cllocationmanager,在此函数之外使用NSLog(@“%@”,longi)会使我的应用程序崩溃。。。。如何在didUpdateToLocation函数之外使用此NSLog?就像在iAction函数中一样 这个例子效果很好!但是如何在这个之外使用这个nslog呢 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldL
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
longi = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
lati = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
NSLog(@"%@",longi);
NSLog(@"%@",lati);
}
您可以将这些值存储在NSUserDefaults中,并在需要时访问它们。K很好,但实际上下次不需要记住这些值,所有事情都发生在同一个视图控制器中,完成后,所有这些值都将无效。然后使用类变量…并将其初始化为某个默认值。在此函数中,您将更新该值。