PDA

View Full Version : passing variables between two classes??




vamsi.ac
Jul 22, 2010, 12:11 PM
MyCLController.m


@synthesize locationManager, delegate, myCLController;

- (id) init
{
self = [super init];
if (self != nil) {
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self; //send location updates to myself



}
return self;
}

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

lon = newLocation.coordinate.longitude;
lat = newLocation.coordinate.latitude;

NSLog(@"CLCOntroller X: %f", -lon);
NSLog(@"CLController Y: %f", lat);



Y4 = (( (1.909271 + lon )*670) / (1.909271-1.890306));
X4 = (((52.486908 - lat)*588) / (52.486908-52.477086));

NSLog(@"x4: %f, y4: %f",X4, Y4 );
//Can i use this X4 and Y4 in my first View controller?

[self.delegate locationUpdate:newLocation];
}



FirstViewController.m


-(IBAction) Loc: (id) sender{

how can print X4 and Y4 here

NSLog(@"lat: %f ", X4 );

NSLog(@"lon: %f", Y4);

//which is printing 0.00000
}



so how to bring those values here and print them???



dejo
Jul 22, 2010, 12:23 PM
http://forums.macrumors.com/showthread.php?t=955886&highlight=between
http://forums.macrumors.com/showthread.php?t=705742&highlight=between
http://forums.macrumors.com/showthread.php?t=699418&highlight=between
...