Jump to content

Try to print location on console in Xcode 4.2

7583237's Photo
Posted Mar 26 2012 10:38 AM
2139 Views

I am developing this program for jailbreak iPhone. My development environment is Xcode 4.2 and the device on which I am trying to run this program is iPhone 3GS with iOS 5.0.1.

Note: It is not GUI based program.

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];

NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop addTimer:currentTimer forMode:NSDefaultRunLoopMode];
[runLoop run];


NSLog(@"EXIT from init()");	

return self;
}


-(void) Action
{
NSLog(@"ENTER in Action");

[locationManager startUpdatingLocation];

NSLog(@"EXIT from Action");
}


-(void)locationManagerCLLocationManager *)manager
didUpdateToLocationCLLocation *)newLocation
fromLocationCLLocation *)oldLocation
{
NSLog(@"ENTER in didUpdateToLocation");


NSLog(@"%f",newLocation.coordinate.latitude);

NSLog(@"%f",newLocation.coordinate.longitude);

[locationManager stopUpdatingLocation];


NSLog(@"EXIT from didUpdateToLocation");
}

The program works perfectly on Simulator.
But when I run this program on actual device, here is the output:

2012-03-26 11:50:20.622 location[369:707] ENTER in main
2012-03-26 11:50:20.632 location[369:707] ENTER in init()
2012-03-26 11:50:40.649 location[369:707] ENTER in Action
2012-03-26 11:50:40.656 location[369:707] EXIT from Action
2012-03-26 11:51:00.648 location[369:707] ENTER in Action
2012-03-26 11:51:00.654 location[369:707] EXIT from Action
and so on .....

Can anybody help me?

Tags:
0 Subscribe


0 Replies