<?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>OniDev &#187; Code Examples</title>
	<atom:link href="http://www.onidev.com/category/code-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onidev.com</link>
	<description>freelance iPhone design &#38; development</description>
	<lastBuildDate>Fri, 03 Sep 2010 14:41:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Disable deprecated warnings with GCC</title>
		<link>http://www.onidev.com/2010/08/27/disable-deprecated-warnings-with-gcc/</link>
		<comments>http://www.onidev.com/2010/08/27/disable-deprecated-warnings-with-gcc/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 10:32:22 +0000</pubDate>
		<dc:creator>Mitch</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Deprecated]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[Warnings]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.onidev.com/?p=298</guid>
		<description><![CDATA[Recently I wrote some conditional code to call various methods depending on the version of iOS running on the device. A problem I came across was that because I still called some deprecated methods I was getting warnings during my build. As I treat all warnings as errors I had to find a solution which [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wrote some conditional code to call various methods depending on the version of iOS running on the device. A problem I came across was that because I still called some deprecated methods I was getting warnings during my build. As I treat all warnings as errors I had to find a solution which would compile. #pragma was the answer.</p>
<p>You can use the following line to disable warnings for depreciated calls:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#pragma GCC diagnostic ignored &quot;-Wdeprecated-declarations&quot;</span></pre></div></div>

<p>And use this to re-enable it:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#pragma GCC diagnostic warning &quot;-Wdeprecated-declarations&quot;</span></pre></div></div>

<p>Here&#8217;s how I used it:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#pragma GCC diagnostic ignored &quot;-Wdeprecated-declarations&quot;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> initWithStyle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableViewCellStyle<span style="color: #002200;">&#41;</span>style reuseIdentifier<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>reuseIdentifier
<span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>super respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>initWithStyle<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
  <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithStyle<span style="color: #002200;">:</span>style reuseIdentifier<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
      <span style="color: #002200;">&#91;</span>self setupCell<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
  <span style="color: #002200;">&#125;</span>
  <span style="color: #a61390;">else</span>
  <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
      <span style="color: #002200;">&#91;</span>self setupCell<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
  <span style="color: #002200;">&#125;</span>
  <span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
<span style="color: #6e371a;">#pragma GCC diagnostic warning &quot;-Wdeprecated-declarations&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.onidev.com/2010/08/27/disable-deprecated-warnings-with-gcc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customisable UIPageControl</title>
		<link>http://www.onidev.com/2009/12/02/customisable-uipagecontrol/</link>
		<comments>http://www.onidev.com/2009/12/02/customisable-uipagecontrol/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 14:12:12 +0000</pubDate>
		<dc:creator>Mitch</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[OMPageControl]]></category>
		<category><![CDATA[UIKit]]></category>
		<category><![CDATA[UIPageControl]]></category>

		<guid isPermaLink="false">http://www.onidev.com/?p=219</guid>
		<description><![CDATA[The UIPageControl has no way of changing the colors of the dots. Kind of annoying right? Well I knocked up a simple solution to customising the look of the UIPageControl.
This class allows you to replace the dots with your own UIImages, with the following 2 properties:

@property &#40;nonatomic, readwrite, retain&#41; UIImage* imageNormal;
@property &#40;nonatomic, readwrite, retain&#41; UIImage* [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_225" class="wp-caption alignright" style="width: 70px"><img src="http://www.onidev.com/wp-content/uploads/2009/12/OMPageControl.gif" alt="PageControl Examples" title="OMPageControl Examples" width="60" height="120" class="size-full wp-image-225" /><p class="wp-caption-text">PageControl Examples</p></div><br />
The UIPageControl has no way of changing the colors of the dots. Kind of annoying right? Well I knocked up a simple solution to customising the look of the UIPageControl.</p>
<p>This class allows you to replace the dots with your own UIImages, with the following 2 properties:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, readwrite, retain<span style="color: #002200;">&#41;</span> UIImage<span style="color: #002200;">*</span> imageNormal;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, readwrite, retain<span style="color: #002200;">&#41;</span> UIImage<span style="color: #002200;">*</span> imageCurrent;</pre></div></div>

<p>It works by replacing the UIImage on the UIImageView containing the original dot.</p>
<p>One word of warning, if Apple change the way the UIPageControl works, this code will most likely break (especially if they change the dots so they are no longer UIImageViews!). However I&#8217;d say the only reason this would happen, is if they add their own functionality in to customise the look of it, so it&#8217;s probably OK.</p>
<p>Here&#8217;s the full code, in all it&#8217;s glory. Feel free to use how you see fit (I&#8217;m releasing this with no restrictions). It&#8217;s not very complicated, but I figured it might be useful to someone!</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> OMPageControl <span style="color: #002200;">:</span> UIPageControl <span style="color: #002200;">&#123;</span>
  UIImage<span style="color: #002200;">*</span> mImageNormal;
  UIImage<span style="color: #002200;">*</span> mImageCurrent;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, readwrite, retain<span style="color: #002200;">&#41;</span> UIImage<span style="color: #002200;">*</span> imageNormal;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, readwrite, retain<span style="color: #002200;">&#41;</span> UIImage<span style="color: #002200;">*</span> imageCurrent;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;OMPageControl.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> OMPageControl <span style="color: #002200;">&#40;</span>Private<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> updateDots;
<span style="color: #a61390;">@end</span>
&nbsp;
&nbsp;
<span style="color: #a61390;">@implementation</span> OMPageControl
&nbsp;
<span style="color: #a61390;">@synthesize</span> imageNormal <span style="color: #002200;">=</span> mImageNormal;
<span style="color: #a61390;">@synthesize</span> imageCurrent <span style="color: #002200;">=</span> mImageCurrent;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> dealloc
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>mImageNormal release<span style="color: #002200;">&#93;</span>, mImageNormal <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
  <span style="color: #002200;">&#91;</span>mImageCurrent release<span style="color: #002200;">&#93;</span>, mImageCurrent <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #11740a; font-style: italic;">/** override to update dots */</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setCurrentPage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>currentPage
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>super setCurrentPage<span style="color: #002200;">:</span>currentPage<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// update dot views</span>
  <span style="color: #002200;">&#91;</span>self updateDots<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">/** override to update dots */</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> updateCurrentPageDisplay
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>super updateCurrentPageDisplay<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// update dot views</span>
  <span style="color: #002200;">&#91;</span>self updateDots<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">/** Override setImageNormal */</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setImageNormal<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>image
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>mImageNormal release<span style="color: #002200;">&#93;</span>;
  mImageNormal <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>image retain<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// update dot views</span>
  <span style="color: #002200;">&#91;</span>self updateDots<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">/** Override setImageCurrent */</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setImageCurrent<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>image
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>mImageCurrent release<span style="color: #002200;">&#93;</span>;
  mImageCurrent <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>image retain<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// update dot views</span>
  <span style="color: #002200;">&#91;</span>self updateDots<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">/** Override to fix when dots are directly clicked */</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> endTrackingWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event 
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>super endTrackingWithTouch<span style="color: #002200;">:</span>touch withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #002200;">&#91;</span>self updateDots<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #6e371a;">#pragma mark - (Private)</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> updateDots
<span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>mImageCurrent || mImageNormal<span style="color: #002200;">&#41;</span>
  <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// Get subviews</span>
    <span style="color: #400080;">NSArray</span><span style="color: #002200;">*</span> dotViews <span style="color: #002200;">=</span> self.subviews;
    <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt; dotViews.count; <span style="color: #002200;">++</span>i<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
      UIImageView<span style="color: #002200;">*</span> dot <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>dotViews objectAtIndex<span style="color: #002200;">:</span>i<span style="color: #002200;">&#93;</span>;
      <span style="color: #11740a; font-style: italic;">// Set image</span>
      dot.image <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>i <span style="color: #002200;">==</span> self.currentPage<span style="color: #002200;">&#41;</span> ? mImageCurrent <span style="color: #002200;">:</span> mImageNormal;
    <span style="color: #002200;">&#125;</span>
  <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.onidev.com/2009/12/02/customisable-uipagecontrol/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
