Tip: Custom User Agent

So remember waaay back when we mentioned how to go about messing with the undocumented internals of UIWebView if you needed to call -setCustomUserAgent for some good reason? Well, we’ve always been mildly nervous about that approach … but now, here is a rather safer way to go about things:

UIWebView user-agent weirdness and how to change user-agent value programmatically

which uses the technique described here,

Changing the headers for UIWebKit HTTP requests

to do some swizzling of NSMutableURLRequest’s setValue:forHTTPHeaderField: method.

A rather massive replacement for a simple declaration of a hidden method yes … but just in case Apple ever starts getting persnickety about people actually using desktop-available calls on the guts of UIWebView, a massive replacement you would be very well advised indeed to adopt!

0 Responses to “Tip: Custom User Agent”

  1. No Comments

Leave a Reply