var placesTask = NSURLSessionDataTask()
var session : NSURLSession{
return NSURLSession.sharedSession()
}
func fetchPlacesNearCoordinate(coordinate: CLLocationCoordinate2D, radius: Double, types:[String], completion: (([GooglePlace]) -> Void)) -> ()
{
var urlString = "https:/ let typesString = types.count > 0 ? types.joinWithSeparator("|") : "food" urlString += "&types=\(typesString)"
urlString = urlString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
if placesTask.taskIdentifier > 0 && placesTask.state == .Running { placesTask.cancel()
}
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
placesTask = session.dataTaskWithURL(NSURL(string: urlString)!) {data, response, error in UIApplication.sharedApplication().networkActivityIndicatorVisible = false
var placesArray = [GooglePlace]() if let json = (try? NSJSONSerialization.JSONObjectWithData(data!, options:[])) as? NSDictionary {
if let results = json["results"] as? NSArray
{
for rawPlace:AnyObject in results
{
let place = GooglePlace(dictionary: rawPlace as! NSDictionary, acceptedTypes: types) placesArray.append(place)
if let reference = place.photoReference
{ self.fetchPhotoFromReference(reference)
{ image in place.photo = image }
}}}
} dispatch_async(dispatch_get_main_queue())
{ completion(placesArray)
}
} placesTask.resume()
}
The error I m getting after compiling :
-[NSURLSessionDataTask taskIdentifier]: unrecognized selector sent to instance 0x7f8eba441e60
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLSessionDataTask taskIdentifier]: unrecognized selector sent to instance 0x7f8eba441e60'
This code seems to work on xcode 6.4 but doesn't work on the xcode 7 beta 6 which is currently using.
Can someone help me for solution?
Thank you