passing variables between two classes??

Discussion in 'iPhone/iPad Programming' started by vamsi.ac, Jul 22, 2010.

  1. macrumors newbie

    Joined:
    Sep 22, 2009
    #1
    MyCLController.m

    Code:
    @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 );
    	[B]//Can i use this X4 and Y4 in my first View controller?[/B]
    	
    	[self.delegate locationUpdate:newLocation];
    }
    

    FirstViewController.m


    -
    Code:
    (IBAction) Loc: (id) sender{
    	
    	[B]how can print X4 and Y4 here[/B]
    	
    	[B]NSLog(@"lat: %f ", X4 );
    	
    	NSLog(@"lon: %f", Y4);[/B] 
    
           //which is printing 0.00000
    }
    

    so how to bring those values here and print them???
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State

Share This Page