Wednesday, October 20, 2010

IPhone GPS

- (CLLocationManager *)locationManager {
NSLog(@"lattttttttiiiiiiiiiiiiiudeeeeeeeee");
if (locationManager != nil) {
return locationManager;
}

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;


return locationManager;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {





//[locationMeasurements addObject:newLocation];


NSLog(@"l89899898ee");

#pragma mark lat


NSString *lat = [[NSString alloc] initWithFormat:@"%0.3f", newLocation.coordinate.latitude];



// NSLog(@"1l89899898ee");

NSString *lonn = [[NSString alloc] initWithFormat:@"%0.3f", newLocation.coordinate.longitude];



//latitudeString =newLocation.coordinate.latitude;
//latitudeString=lat;
//NSLog(@"lat is %@", lat);
//self.myLatitude = latitudeString;
//[latitudeString release];
#pragma mark long

//NSLog(@"2l89899898ee");

NSUserDefaults *alat = [NSUserDefaults standardUserDefaults];
[alat setObject:lat forKey:@"Latitude"];
//NSLog(@"%@",latitudeString);


//NSLog(@"3l89899898ee");
NSUserDefaults *along = [NSUserDefaults standardUserDefaults];
[along setObject:lonn forKey:@"Longitude"];

//NSLog(@"lon fgfgfgfg is %@", lonn);
//longitudeString=newLocation.coordinate.longitude;
//longitudeString=lon;

//NSLog(@"4l89899898ee");



}

- (void)locationManager: (CLLocationManager *)manager didFailWithError: (NSError *)error
{
NSLog(@"Location Error: %@",error);
switch([error code])
{
case kCLErrorNetwork: // general, network-related error
{
NSLog(@"please check your network connection or that you are not in airplane mode");
}
break;
case kCLErrorDenied:{
NSLog(@"user has denied to use current Location");
}
break;
default:
{
NSLog(@"unknown network error");
}
break;
}
[manager stopUpdatingLocation];
}



- (void)starte {

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];



NSLog(@" thread stretr ");
[[self locationManager] startUpdatingLocation];


NSLog(@" main tgreas point is %@",latitudeString);







NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

// getting an NSString
NSString *Latu = [prefs stringForKey:@"Latitude"];
NSLog(@" new lati is %@",Latu);





NSUserDefaults *alongs = [NSUserDefaults standardUserDefaults];
NSString *Longu = [alongs stringForKey:@"Longitude"];

NSLog(@" new longu is %@",Longu);


#pragma mark APP iD

#pragma mark sysID
NSString *sysID=[[UIDevice currentDevice] uniqueIdentifier];
NSLog(@" ID IS %@",sysID);

NSString *ip=@"ip";
NSString* OS=@"3";

//NSLog(@"latitude is %@", myString );
//latitudeString=@"1.3";
//longitudeString=@"103.8";

NSString *AppID=[NSString stringWithFormat:@"%@|%@|%@|%@|%@",Latu,Longu,sysID,ip,OS];
NSLog(@" MY APPLE OD IS %@",AppID );


NSUserDefaults *aDD = [NSUserDefaults standardUserDefaults];
[aDD setObject:AppID forKey:@"AppID"];

///////////////////////////////////////////////////////////////////////

[pool drain];
[pool release];



}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[self locationManager] startUpdatingLocation];
[self performSelectorInBackground:@selector(starte) withObject:nil];
}

No comments:

FEEDJIT Live