I am new to iphone development.I am creating a map application.I have used following code in header file
@interface BrusMapSubviewcontroller : UIViewController<UIApplicationDelegate,CLLocationManagerDelegate> {
IBOutlet MKMapView *mapView;
IBOutlet UIToolbar *toolbar;
IBOutlet UIButton *location;
IBOutlet UIButton *backtocampus;
CLLocationManager *locationManager;
}
@property(retain,nonatomic) IBOutlet UIToolbar *toolbar;
@property(retain,nonatomic) IBOutlet UIButton *location;
@property(retain,nonatomic)IBOutlet UIButton *backtocampus;
@property (nonatomic, retain) CLLocationManager *locationManager;
-(IBAction) gosearch : (id) sender;
-(IBAction) backtocampus: (id)sender;
In the implementation class
-(IBAction) gosearch : (id) sender{
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
[locationManager startUpdatingLocation];
NSLog(@"inside go search");
}
-(IBAction) backtocampus: (id)sender{
MKCoordinateRegion region;
region.center.latitude=41.825672;
region.center.longitude=-71.402695;
region.span.latitudeDelta=0.001551;
region.span.longitudeDelta=0.005493;
mapView.mapType=MKMapTypeHybrid;
mapView.region=region;
NSLog(@"inside back to campus");
}
- (void)locationManager: (CLLocationManager *)manager
didUpdateToLocation: (CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[manager stopUpdatingLocation];
NSLog(@"inside update");
printf("\n Latitude = %s\n Longitude = %s",[NSString stringWithFormat:@"%.7f",newLocation.coordinate.latitude],[NSString stringWithFormat:@"%.7f",newLocation.coordinate.longitude]);
}
- (void)locationManager: (CLLocationManager *)manager
didFailWithError: (NSError *)error
{
printf("\nerror");
}
When i run in simulator "inside update" is printed in console and long and lat values.But if i run in ipod "inside go search" is alone printed in console.Why there is difference output in simulator and device.Thanks.