<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Profios Ltd</title>
	<atom:link href="http://www.profios.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.profios.com</link>
	<description>iPhone &#38; iPad application development</description>
	<lastBuildDate>Sat, 27 Oct 2012 19:14:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Facebook+Batch category</title>
		<link>http://www.profios.com/facebookbatch/</link>
		<comments>http://www.profios.com/facebookbatch/#comments</comments>
		<pubDate>Fri, 13 Jul 2012 14:51:48 +0000</pubDate>
		<dc:creator>Maarten de Zwart</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.profios.com/?p=317</guid>
		<description><![CDATA[Lately I have been using the Facebook iOS SDK. Integration is really easy and also requesting information from the Graph API couldn&#8217;t be more straight forward. When working on retrieving some information using more difficult requests I found batching my<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.profios.com/facebookbatch/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>Lately I have been using the <a title="Facebook iOS SDK reference" href="https://developers.facebook.com/docs/reference/iossdk/" target="_blank">Facebook iOS SDK</a>. Integration is really easy and also requesting information from the Graph API couldn&#8217;t be more straight forward.</p>
<p>When working on retrieving some information using more difficult requests I found batching my requests most convenient. It actually allows you to use the results from one request as input to the next.<br />
However it did take some effort to find out how to actually get it working smoothly. After that I found myself using Batching over and over again, so it needed an easy to use interface to do so.</p>
<h2>The Facebook+Batch category!</h2>
<p>The Facebook Batch category adds some interfaces to construct and request a batch using your existing Facebook instance.<br />
First there are the <code>batchAddRequestWithPath:</code> interfaces which will add requests to an <code>requests</code> array associated with your Facebook instance.<br />
Once you added all instances the actual request can be made with <code>batchRequestWithDelegate:</code><br />
The great thing of this being an category is that you just include <code>Facebook+Batch</code> and magically you can make batch requests on your Facebook instance.</p>
<p>As simple usage example of a batch request would be:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Facebook instance initialized and ready as facebook</span>
<span style="color: #002200;">&#91;</span>facebook batchAddRequestWithPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;me&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>facebook batchAddRequestWithPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;me/friends?fields=id&amp;amp;limit=5&quot;</span>
                             name<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;myfriends&quot;</span>
                           method<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;GET&quot;</span>
                             body<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span>
                     omitResponse<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>facebook batchAddRequestWithPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;?ids={result=myfriends:$.data.*.id}&quot;</span><span style="color: #002200;">&#93;</span>;
FBRequest <span style="color: #002200;">*</span>batchRequest <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>facebook batchRequestWithDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// expect results in your FBRequestDelegate implementation</span></pre></td></tr></table></div>

<p>I released the Facebook+Batch category to public on <a title="git-hub" href="https://github.com/Profios/ios-facebook-batch/" target="_blank">git-hub</a></p>
<p>Please let know if you use it or when you have questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.profios.com/facebookbatch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kuopionkirppari.fi iPhone app</title>
		<link>http://www.profios.com/kirppari/</link>
		<comments>http://www.profios.com/kirppari/#comments</comments>
		<pubDate>Mon, 28 May 2012 09:29:50 +0000</pubDate>
		<dc:creator>Maarten de Zwart</dc:creator>
				<category><![CDATA[portfolio]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.profios.com/?p=287</guid>
		<description><![CDATA[Kuopionkirppari.fi offers a great platform for buying and selling locally for private use. Its a great way to contact the local market and exchange secondhand goods for new use. Profios Ltd has build an iPhone application which runs on all<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.profios.com/kirppari/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.kuopionkirppari.fi" title="Kuopionkirppari.fi" target="_blank">Kuopionkirppari.fi</a> offers a great platform for buying and selling locally for private use. Its a great way to contact the local market and exchange secondhand goods for new use.<br />
<img src="http://www.profios.com/wp-content/uploads/2012/05/KuopionKirppari.png" alt="" title="KuopionKirppari" width="249" height="449" class="alignright size-full wp-image-296" /><br />
Profios Ltd has build an iPhone application which runs on all devices, iPhones, iPod touches and iPad (in compatibility mode).<br />
To complement the services provided by the website, the application allows the user to:</p>
<ul>
<li>browse the advertisements with fast scrolling</li>
<li>call, text or email the seller straight from the application</li>
<li>view the pictures fullscreen</li>
<li>search advertisement by keywords</li>
<li>Post a new advertisement with pictures</li>
</ul>
<p>Profios Ltd has integrated the application into the web service with HTTP GET and POST calls, communication is JSON encoded and optimized for mobile use. Images can be shot with the camera, if available on the device, or selected from the user pictures library. The user interface is native components for optimum performance but customized to the look and feel of Kuopionkirppari.fi.</p>
<p>The design is provided by <a href="http://www.designsapiens.com" title="Pasi Lehtinen" target="_blank">Pasi Lehtinen</a>, a great designer with excellent iOS design skills.</p>
<p>More information on the application you can find <a href="http://www.kuopionkirppari.fi/iphone" title="Kuopionkirppari.fi iPhone App" target="_blank">here</a></p>
<p><a href="http://itunes.apple.com/fi/app/kuopionkirppari.fi/id530412585?mt=8" target="_blank" title="Kuopionkirppari.fi in the App Store"><img src="http://www.profios.com/wp-content/uploads/2012/06/appstore_badge.png" width="160" height="61"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.profios.com/kirppari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AFNetworking, image loading and cache handling</title>
		<link>http://www.profios.com/afnetworking-image-loading-and-cache-handling/</link>
		<comments>http://www.profios.com/afnetworking-image-loading-and-cache-handling/#comments</comments>
		<pubDate>Wed, 23 May 2012 13:04:39 +0000</pubDate>
		<dc:creator>Maarten de Zwart</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://beta.profios.com/?p=118</guid>
		<description><![CDATA[If you hit this page you probably already know about AFNetworking the great open source library handling you applications network communication. I have found it really easy to integrate and use, and if it doesn&#8217;t have a specific feature which<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.profios.com/afnetworking-image-loading-and-cache-handling/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>If you hit this page you probably already know about <a href="https://github.com/AFNetworking" title="AFNetworking" target="_blank">AFNetworking</a> the great open source library handling you applications network communication.</p>
<p>I have found it really easy to integrate and use, and if it doesn&#8217;t have a specific feature which you need, its really easy to extend.</p>
<p>For example I wanted to track the loading of the images, so I updated some UIImageView+AFNetworking category interfaces to support a download progress block, basically it all boils down to this:</p>
<p><strong>UIImageView+AFNetworking.h</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setImageWithURLRequest<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>urlRequest 
              placeholderImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>placeholderImage 
                       success<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span>request, <span style="color: #400080;">NSHTTPURLResponse</span> <span style="color: #002200;">*</span>response, UIImage <span style="color: #002200;">*</span>image<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>success
                       failure<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span>request, <span style="color: #400080;">NSHTTPURLResponse</span> <span style="color: #002200;">*</span>response, <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>failure
         downloadProgressBlock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>block;</pre></td></tr></table></div>

</p>
<p><strong>UIImageView+AFNetworking.m</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setImageWithURLRequest<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>urlRequest 
              placeholderImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>placeholderImage 
                       success<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span>request, <span style="color: #400080;">NSHTTPURLResponse</span> <span style="color: #002200;">*</span>response, UIImage <span style="color: #002200;">*</span>image<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>success
                       failure<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span>request, <span style="color: #400080;">NSHTTPURLResponse</span> <span style="color: #002200;">*</span>response, <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>failure
         downloadProgressBlock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>NSInteger, NSInteger, NSInteger<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>block
<span style="color: #002200;">&#123;</span>
    ...
        <span style="color: #11740a; font-style: italic;">// Add the downloadProgressBlock to the request operation before execution.</span>
        <span style="color: #002200;">&#91;</span>requestOperation setDownloadProgressBlock<span style="color: #002200;">:</span>block<span style="color: #002200;">&#93;</span>;
    ...
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

</p>
<h2>AFNetworking disable caching</h2>
<p>Another thing I noticed that by default all AFHTTPRequestOperations are cached if allow by the server, or at least they are using the cachePolicy: NSURLRequestUseProtocolCachePolicy, which defaults it to caching.</p>
<p>There are several possible ways to solve this issue, you can configure the server not to do caching (it should know best what to cache and what not), and the AFURLConnectionOperation (of which AFHTTPRequestOperation is inheriting) provides methods where you can set a cache response callback:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setCacheResponseBlock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSCachedURLResponse</span> <span style="color: #002200;">*</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLConnection</span> <span style="color: #002200;">*</span>connection, <span style="color: #400080;">NSCachedURLResponse</span> <span style="color: #002200;">*</span>cachedResponse<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>block;</pre></td></tr></table></div>

<p>But I preferred to handle this by setting the cache policy for my requests as following:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSMutableURLRequest</span> <span style="color: #002200;">*</span>request <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self requestWithMethod<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;GET&quot;</span>
                                                      path<span style="color: #002200;">:</span>kRequestPath
                                                parameters<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// Do not allow to use a cached version for this request</span>
<span style="color: #002200;">&#91;</span>request setCachePolicy<span style="color: #002200;">:</span>NSURLRequestReloadIgnoringCacheData<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.profios.com/afnetworking-image-loading-and-cache-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
