Matching URLSession redirect handlers by Objective-C selector, not Swift name
The author describes a lint rule for an iOS app that stops credentials from being sent to self-hosted servers during redirects. URLSession finds the redirect delegate method through an Objective-C selector rather than the Swift name, so the rule has to match the selector. Swift 6 rejects an explicit @objc selector on classes conforming to URLSessionTaskDelegate, but a class adopting only URLSessionDelegate still receives the call. A method named with capitalized URLSession and the matching labels also gets the selector through inference, and types play no role in it. The author tests each shape by checking runtime responses and running redirects against a local server.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in