I am developing for jailbreak iPhones. I am reading Beginning iOS 5 book. Currently, I have used a location code from the book and changed it slightly. The change which I have made in the code is that I am trying to print location on console.
Note: I don't need GUI based solution. And I am building this code in Xcode 4.2 and the iPhone on which I am trying to run this code has iOS 5.0.1 (9A405).
Here is the code:
Now, the only output which is visible on the screen is
2012-03-22 18:26:23.451 location[437:207] ENTER in main
2012-03-22 18:26:23.533 location[437:207] ENTER in init()
2012-03-22 18:26:23.609 location[437:207] EXIT from init()
2012-03-22 18:26:23.647 location[437:207] EXIT from main
Note: I don't need GUI based solution. And I am building this code in Xcode 4.2 and the iPhone on which I am trying to run this code has iOS 5.0.1 (9A405).
Here is the code:
Code:
int main(int argc, char *argv[])
{
NSLog(@"ENTER in main");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
locationAppDelegate *loc = [[locationAppDelegate alloc] init];
[pool drain];
NSLog(@"EXIT from main");
}
-(id) init
{
NSLog(@"ENTER in init()");
[super init];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
NSTimer *currentTimer = [NSTimer scheduledTimerWithTimeInterval:20.0 target:self
selector:@selector(Action)
userInfo:nil
repeats:YES];
NSLog(@"EXIT from init()");
return self;
}
-(void) Action
{
NSLog(@"ENTER in Action");
[locationManager startUpdatingLocation];
NSLog(@"EXIT from Action");
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"ENTER in didUpdateToLocation");
NSLog(@"%f",newLocation.coordinate.latitude);
NSLog(@"%f",newLocation.coordinate.longitude);
[locationManager stopUpdatingLocation];
NSLog(@"EXIT from didUpdateToLocation");
}
2012-03-22 18:26:23.451 location[437:207] ENTER in main
2012-03-22 18:26:23.533 location[437:207] ENTER in init()
2012-03-22 18:26:23.609 location[437:207] EXIT from init()
2012-03-22 18:26:23.647 location[437:207] EXIT from main
Last edited by a moderator: