this is my code.getting this EXC_BAD_ACCESS(code=EXC_i386_GPFLT).I don'n know how to find and solve plz help me ...application getting crash when get longitude
mapServerRequest="Hyderabad,india"
var mapAddress:NSString=mapServerRequest
mapAddress.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet())
println(mapAddress)
var urlpath=NSString(format: "http://maps.googleapis.com/maps/api/geocode/json?address=%@", mapAddress)
println(urlpath)
var url = NSURL.URLWithString(urlpath)
println(url)
var jsonData:NSData=NSData(contentsOfURL:url)
if(jsonData != nil)
{
var error:NSError=NSError(coder: nil)
var result:NSDictionary=NSJSONSerialization .JSONObjectWithData(jsonData, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary
//println(result)
if (error != nil)
{
mapServerResultArray=result.valueForKey("results") as NSMutableArray
// println(mapServerResultArray)
}
var longitud:NSString
longitud=mapServerResultArray.objectAtIndex(0).valueForKey("geometry").valueForKey("location").valueForKey("lng")as NSString
var latitud :NSString = (mapServerResultArray .objectAtIndex(0).valueForKey("geometry").valueForKey("location").valueForKey("lat")) as NSString
placeName=mapServerResultArray .objectAtIndex(0).valueForKey("formatted_address") as NSString
var longitude:Float=longitud.floatValue
var latitude:Float=latitud.floatValue
self.zoomMapAndCenterAtLatitude(latitude)
self.zoomMapAndCenterAtLongitud(longitude)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…