Found a fun little bug the other day in MapKit.

If you create a MKLocalPointsOfInterestRequest with a negative radius the constructor returns nil but the swift declaration does not expect an optional response.

Passing this to MKLocalSearch results in a crash.

#iOSDev #SwiftLang

@hishnash worst kind of bridging bug! I hate those.
@marcpalmer yer took me over a day to trace it down (I was not intending to pass negative radius) the worst part is since swift thinks the value is non optional, if let/guard let appear to be optimised away and continue with a nill value. For a while I was chancing down if it was the automatic reference counting going bad due to async and garbage collecting the request to soon or something.
@hishnash @marcpalmer FWIW in cases like these the compiler is not supposed to optimize out immediate casts to optional values (after which you can perform the check as usual)