     
     func geocodeUsingGoogleAddressString(#address:NSString, onGeocodingCompletionHandler:((address:NSDictionary?, error:String?)->Void)?){
         
-        
         self.geocodingCompletionHandler = onGeocodingCompletionHandler
         
-        
         geoCodeUsignGoogleAddress(address)
     }
     

            
    }
    
    func reverseGeocodeLocationWithLatLon(#latitude:Double, longitude: Double,onReverseGeocodingCompletionHandler:((address:NSDictionary?, error:String?)->Void)?){
        
        var location:CLLocation = CLLocation(latitude:latitude, longitude: longitude)
        reverseGeocodeLocationWithCoordinates(location,onReverseGeocodingCompletionHandler)
        
        
    }
    
    func reverseGeocodeLocationWithCoordinates(coord:CLLocation, onReverseGeocodingCompletionHandler:((address:NSDictionary?, error:String?)->Void)?){
        
        
        self.reverseGeocodingCompletionHandler = onReverseGeocodingCompletionHandler
        
        
        reverseGocode(coord)
    }
    
    private func reverseGocode(location:CLLocation){
        
        var geocoder: CLGeocoder = CLGeocoder()
        
        
        geocoder.reverseGeocodeLocation(location, completionHandler: {(placemarks, error)->Void in
            

            
            if(error){
                
                if(type == GeoCodingType.Geocoding){
                    
                    self.geocodingCompletionHandler!(address: nil,error: error.localizedDescription)
                    
                }else{
                    
                    self.reverseGeocodingCompletionHandler!(address: nil,error: error.localizedDescription)
                    
                }
            }else{
                
                let dataAsString: NSString = NSString(data: data, encoding: NSUTF8StringEncoding)
                
                // Convert the retrieved data in to an object through JSON deserialization
                var err: NSError
                let jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary
                
                var status = jsonResult.valueForKey("status") as NSString
                
                if((status.lowercaseString as NSString).isEqualToString("ok")){
                    
                    let address = AddressParser()
                    
                    address.parseGoogleLocationData(jsonResult)
                    
                    let addressDict = address.addressDictionary()
                    
                    if(type == GeoCodingType.Geocoding){
                        
                        self.geocodingCompletionHandler!(address: addressDict,error: nil)
                        
                    }else{
                        
                        self.reverseGeocodingCompletionHandler!(address: addressDict,error: nil)
                    }
                    
                }else{
                    if(type == GeoCodingType.Geocoding){
                        
                        self.geocodingCompletionHandler!(address: nil,error: "invalid address")
                        
                    }else{
                        
                        self.reverseGeocodingCompletionHandler!(address: nil,error: "invalid latitude")
                    }
                    
                }
                
            }
            }
        )
        
    }
}


