<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: URL filtering for UIWebView on the iPhone</title>
	<atom:link href="http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/</link>
	<description>iCab related stuff; Mac, iPhone and Cocoa programming</description>
	<lastBuildDate>Wed, 15 May 2013 09:32:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-61558</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Tue, 23 Apr 2013 13:56:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-61558</guid>
		<description><![CDATA[@Max Litteral
The criteria for blocking URLs is completely up to you. In simply basic cases this could be done by a simple string comparison, for more complex filtering requirements you may need to do some more. I don&#039;t know what exactly you need to filter, so I can&#039;t tell you how this needs to be done.

For example the following would block the www.apple.com site and all secure web sites using the HTTPS scheme:
&lt;pre&gt;
- (BOOL)shouldBlockURL:(NSURL*)url
{
  if ([[url host] isEqualToString:@&quot;www.apple.com&quot;]) {
    return YES;
  } else if ([[url scheme] isEqualToString:@&quot;https&quot;]) {
    return YES;
  }
  return NO;
}
&lt;/pre&gt;

For more complex filtering you would have an array of URLs or URL parts you would check against in a loop, so the filter manager class would also need methods to load and maintain the list of filters (URLs or URL components) etc. This is why I&#039;ve assumed to do this in a special &quot;filter manager&quot; class. But depending of our requirements, you can do this differently as well.]]></description>
		<content:encoded><![CDATA[<p>@Max Litteral<br />
The criteria for blocking URLs is completely up to you. In simply basic cases this could be done by a simple string comparison, for more complex filtering requirements you may need to do some more. I don&#8217;t know what exactly you need to filter, so I can&#8217;t tell you how this needs to be done.</p>
<p>For example the following would block the <a href="http://www.apple.com" rel="nofollow">http://www.apple.com</a> site and all secure web sites using the HTTPS scheme:</p>
<pre>
- (BOOL)shouldBlockURL:(NSURL*)url
{
  if ([[url host] isEqualToString:@"www.apple.com"]) {
    return YES;
  } else if ([[url scheme] isEqualToString:@"https"]) {
    return YES;
  }
  return NO;
}
</pre>
<p>For more complex filtering you would have an array of URLs or URL parts you would check against in a loop, so the filter manager class would also need methods to load and maintain the list of filters (URLs or URL components) etc. This is why I&#8217;ve assumed to do this in a special &#8220;filter manager&#8221; class. But depending of our requirements, you can do this differently as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Litteral</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-61557</link>
		<dc:creator>Max Litteral</dc:creator>
		<pubDate>Tue, 23 Apr 2013 00:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-61557</guid>
		<description><![CDATA[How are you checking the url in the FilterManager.h? could you please post your code]]></description>
		<content:encoded><![CDATA[<p>How are you checking the url in the FilterManager.h? could you please post your code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-61555</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Mon, 22 Apr 2013 13:31:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-61555</guid>
		<description><![CDATA[@zack
The filter manager class would be not an iOS-specific thing. It&#039;s just a normal class which has a method where you pass in a URL and which then returns wether this URL should be filtered or not. How exactly you&#039;re doing this is up to you. If your filtering requirements are very simple, then it could be even OK if you do not write a separate class, but instead just add another method in the FilteredWebCache class which decides if a URL needs to be filtered.]]></description>
		<content:encoded><![CDATA[<p>@zack<br />
The filter manager class would be not an iOS-specific thing. It&#8217;s just a normal class which has a method where you pass in a URL and which then returns wether this URL should be filtered or not. How exactly you&#8217;re doing this is up to you. If your filtering requirements are very simple, then it could be even OK if you do not write a separate class, but instead just add another method in the FilteredWebCache class which decides if a URL needs to be filtered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zack</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-61554</link>
		<dc:creator>zack</dc:creator>
		<pubDate>Mon, 22 Apr 2013 12:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-61554</guid>
		<description><![CDATA[how cn i create Filtermanager class here??i am new  in iOS]]></description>
		<content:encoded><![CDATA[<p>how cn i create Filtermanager class here??i am new  in iOS</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-40103</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Mon, 05 Nov 2012 00:32:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-40103</guid>
		<description><![CDATA[@Jonathan
Yes, this should still work under iOS 6. 
But please be aware that the UIWebView is also doing some caching internally as well. So the NSURLCache won&#039;t get asked each time a resource is requested.]]></description>
		<content:encoded><![CDATA[<p>@Jonathan<br />
Yes, this should still work under iOS 6.<br />
But please be aware that the UIWebView is also doing some caching internally as well. So the NSURLCache won&#8217;t get asked each time a resource is requested.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-40101</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Mon, 05 Nov 2012 00:25:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-40101</guid>
		<description><![CDATA[Hi Alexander,

Does this still work on iOS 6.0?]]></description>
		<content:encoded><![CDATA[<p>Hi Alexander,</p>
<p>Does this still work on iOS 6.0?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-33248</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Fri, 17 Aug 2012 13:07:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-33248</guid>
		<description><![CDATA[@Suvarna
You can not access or clear the internal memory caches of UIWebView. If you call the &quot;reload&quot; method of  UIWebView, it will bypass the cache (NSURLCache) and load the page directly. This way the image can end up in the memory cache. 

To avoid this you either have to implement your own HTTP protocol handler (by implementing the methods of the NSURLProtocol class) so you can intercept every single network request of UIWebView, or you only need to make sure that you never use the &quot;reload&quot; method of UIWebView.]]></description>
		<content:encoded><![CDATA[<p>@Suvarna<br />
You can not access or clear the internal memory caches of UIWebView. If you call the &#8220;reload&#8221; method of  UIWebView, it will bypass the cache (NSURLCache) and load the page directly. This way the image can end up in the memory cache. </p>
<p>To avoid this you either have to implement your own HTTP protocol handler (by implementing the methods of the NSURLProtocol class) so you can intercept every single network request of UIWebView, or you only need to make sure that you never use the &#8220;reload&#8221; method of UIWebView.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suvarna</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-33238</link>
		<dc:creator>Suvarna</dc:creator>
		<pubDate>Fri, 17 Aug 2012 10:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-33238</guid>
		<description><![CDATA[hi alexander,
this code working fine with me,but i have one problem.i can block images on webpage but if i refresh web page  more than 2 times it show me blocked images.i think it use main memory cache for loading.can you give me solution for solve this problem.How to clear cache of main memory?
Thanks 
-Suvarna.]]></description>
		<content:encoded><![CDATA[<p>hi alexander,<br />
this code working fine with me,but i have one problem.i can block images on webpage but if i refresh web page  more than 2 times it show me blocked images.i think it use main memory cache for loading.can you give me solution for solve this problem.How to clear cache of main memory?<br />
Thanks<br />
-Suvarna.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-29829</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Sat, 30 Jun 2012 12:32:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-29829</guid>
		<description><![CDATA[@Bennsen
The &quot;?&quot; icon in the web view is a replacement for missing images, which means the web view has requested an image, but the data it received could not be interpreted as image, or there was no data at all. So if you want to get rid if the replacement images you would need to return valid image data, like for example the data of an 1*1 px transparent GIF image, which would then be completely invisible. 

But depending of the task you want to achieve, it can be nevertheless be a good idea to show these &quot;missing image&quot; icons to make it obvious that you&#039;ve blocked something. At least if the filter is a feature the user can control (like for example in iCab Mobile). This way the user can see that there&#039;s something blocked, and if it is obvious that something important is missing on the page, the user has the chance to suspect an over-blocking filter and can do something to fix this. But he has to see that something is blocked to get suspicious.]]></description>
		<content:encoded><![CDATA[<p>@Bennsen<br />
The &#8220;?&#8221; icon in the web view is a replacement for missing images, which means the web view has requested an image, but the data it received could not be interpreted as image, or there was no data at all. So if you want to get rid if the replacement images you would need to return valid image data, like for example the data of an 1*1 px transparent GIF image, which would then be completely invisible. </p>
<p>But depending of the task you want to achieve, it can be nevertheless be a good idea to show these &#8220;missing image&#8221; icons to make it obvious that you&#8217;ve blocked something. At least if the filter is a feature the user can control (like for example in iCab Mobile). This way the user can see that there&#8217;s something blocked, and if it is obvious that something important is missing on the page, the user has the chance to suspect an over-blocking filter and can do something to fix this. But he has to see that something is blocked to get suspicious.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bennsen</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-29827</link>
		<dc:creator>Bennsen</dc:creator>
		<pubDate>Sat, 30 Jun 2012 12:11:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-29827</guid>
		<description><![CDATA[hi alexander,
it works perfect - thanks for sharing - but when i ad more than 3 Ads-block-urls i get the “?” icon too.
did you found any solution to replace / remove them?]]></description>
		<content:encoded><![CDATA[<p>hi alexander,<br />
it works perfect &#8211; thanks for sharing &#8211; but when i ad more than 3 Ads-block-urls i get the “?” icon too.<br />
did you found any solution to replace / remove them?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amy</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-27123</link>
		<dc:creator>Amy</dc:creator>
		<pubDate>Thu, 17 May 2012 06:35:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-27123</guid>
		<description><![CDATA[@Alexander
Thank for your kindly help. BTW, how can i clear the cache in the memory and is there another general way to detect image urls instead of extension names.]]></description>
		<content:encoded><![CDATA[<p>@Alexander<br />
Thank for your kindly help. BTW, how can i clear the cache in the memory and is there another general way to detect image urls instead of extension names.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-27105</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Wed, 16 May 2012 19:21:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-27105</guid>
		<description><![CDATA[@Nick
It is very important to set your own cache object as the new sharedURLCache. And do this before you create the UIWebView or at least before you load any data in the UIWebView. UIWebView is using memory caches internally, so if a certain resource is still in the memory cache, UIWebView won&#039;t check the NSURLCache.]]></description>
		<content:encoded><![CDATA[<p>@Nick<br />
It is very important to set your own cache object as the new sharedURLCache. And do this before you create the UIWebView or at least before you load any data in the UIWebView. UIWebView is using memory caches internally, so if a certain resource is still in the memory cache, UIWebView won&#8217;t check the NSURLCache.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-27101</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Wed, 16 May 2012 18:44:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-27101</guid>
		<description><![CDATA[Hi,
I was trying to implement this method to modify the urls on outgoing resource requests made by a uiwebview. I follow the tutorial and set up the sharedURL cache to be the sublcassed cache before anything is loaded in the uiwebview. In the subclassed method, I create a modified NSURLRequest with the modified url and return it in the method [super cachedResponseForRequest:request]. However, the uiwebview does not load the modified url for the resource, but instead just loads the original url. What am I doing wrong in this method?]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
I was trying to implement this method to modify the urls on outgoing resource requests made by a uiwebview. I follow the tutorial and set up the sharedURL cache to be the sublcassed cache before anything is loaded in the uiwebview. In the subclassed method, I create a modified NSURLRequest with the modified url and return it in the method [super cachedResponseForRequest:request]. However, the uiwebview does not load the modified url for the resource, but instead just loads the original url. What am I doing wrong in this method?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-27030</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Tue, 15 May 2012 11:42:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-27030</guid>
		<description><![CDATA[@Eric
An adblocker is very similar. Instead of checking the extension, simply check for the well known domain names of ad networks (like double-click.net) and common parts of path names like &quot;banner&quot;, &quot;ads&quot; etc.]]></description>
		<content:encoded><![CDATA[<p>@Eric<br />
An adblocker is very similar. Instead of checking the extension, simply check for the well known domain names of ad networks (like double-click.net) and common parts of path names like &#8220;banner&#8221;, &#8220;ads&#8221; etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.icab.de/blog/2009/08/18/url-filtering-with-uiwebview-on-the-iphone/comment-page-2/#comment-27026</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 15 May 2012 08:32:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=35#comment-27026</guid>
		<description><![CDATA[hi
Following you tutorial  i have  finished the image filter,but how i can make adblock? keyWords or other method? thank you so much.]]></description>
		<content:encoded><![CDATA[<p>hi<br />
Following you tutorial  i have  finished the image filter,but how i can make adblock? keyWords or other method? thank you so much.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
