In my case, it turned out that the problem was the last use of this dictionary when I tried to get subtasks from it. To be exact in this code:
var location: CLLocation? = nil if let geometryDictionary = json["geometry"], locationDictionary = geometryDictionary["location"], latitude = locationDictionary["lat"] as? CLLocationDegrees, longitude = locationDictionary["lng"] as? CLLocationDegrees { location = CLLocation(latitude: latitude, longitude: longitude) }
The problem was that I got the geometryDictionary and locationDictionary links without specifying their type, so the compiler suggested that they are AnyObject. I could still get my value from a dictionary, so the code worked. When I added a type to them, the leaks stopped.
var location: CLLocation? = nil if let geometryDictionary = json["geometry"] as? [String : AnyObject], locationDictionary = geometryDictionary["location"] as? [String : AnyObject], latitude = locationDictionary["lat"] as? CLLocationDegrees, longitude = locationDictionary["lng"] as? CLLocationDegrees { location = CLLocation(latitude: latitude, longitude: longitude) }
source share