0

Is it possible to ignore the proxy settings that are in the device network settings, and instead use no proxy when using an NSURLSession ?

Basically I want to fall back on using no proxy if the connection fails.

Thanks !

GuybrushThreepwood
  • 5,598
  • 9
  • 55
  • 113

1 Answers1

3

I'm pretty sure that providing an empty connectionProxyDictionary in a session configuration should do the trick. Note that it must be an actual empty dictionary. Setting it to nil uses the default system proxy settings.

dgatwood
  • 10,129
  • 1
  • 28
  • 49
  • I wonder why this worked – frank Aug 29 '22 at 08:37
  • 1
    Because there had to be a way to distinguish between "use the default settings" and "use no settings", and treating a NULL/nil value as "use defaults" is cheaper than providing a separate boolean property somewhere, I'd imagine. :-) – dgatwood Sep 04 '22 at 04:54