<?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>Notes of a Developer &#187; work</title>
	<atom:link href="http://www.developers-life.com/tag/work/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developers-life.com</link>
	<description>Develop on Objective-C, UIKit, C, OpenGL for  iPhone, iPad, Mac OS X</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:49:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Color Picker for iOS</title>
		<link>http://www.developers-life.com/color-picker-for-ios.html</link>
		<comments>http://www.developers-life.com/color-picker-for-ios.html#comments</comments>
		<pubDate>Sat, 29 Oct 2011 12:17:25 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[UIColor]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[Ukraine]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1302</guid>
		<description><![CDATA[Example: 1234567891011121314151617181920212223242526272829303132333435363738394041- &#40;void&#41;viewDidLoad &#123; &#160; &#160; &#91;super viewDidLoad&#93;; &#160; &#160; &#160; &#160; // Do any additional setup after loading the view, typically from a nib. &#160; &#160; &#160; &#160; if &#40;self.cPicker == nil&#41; &#123; &#160; &#160; &#160; &#160; &#91;self.view setBackgroundColor:&#91;UIColor grayColor&#93;&#93;; &#160; &#160; &#160; &#160; self.cPicker = &#91;&#91;VBColorPicker alloc&#93; initWithFrame:CGRectMake&#40;0, 0, 202, 202&#41;&#93;; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.developers-life.com/wp-content/uploads/2011/10/Screen-Shot-Color-Picker.png"><img class="alignnone size-full wp-image-1303" title="Screen Shot Color Picker" src="http://www.developers-life.com/wp-content/uploads/2011/10/Screen-Shot-Color-Picker.png" alt="" width="317" height="595" /></a></p>
<p>Example:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// Do any additional setup after loading the view, typically from a nib.</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self.cPicker <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self.view setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor grayColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; self.cPicker <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>VBColorPicker alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">202</span>, <span style="color: #2400d9;">202</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker setCenter<span style="color: #002200;">:</span>self.view.center<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>_cPicker<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker setDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker showPicker<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// set default YES!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker setHideAfterSelection<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// set color from picker</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> pickedColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>color <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_rect setBackgroundColor<span style="color: #002200;">:</span>color<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker hidePicker<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> touchesBegan<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches 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><br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span>_cPicker isHidden<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker hidePicker<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// show picker by double touch</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> touchesEnded<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches 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><br />
&nbsp; &nbsp; UITouch <span style="color: #002200;">*</span>touch <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>touches anyObject<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>touch.tapCount <span style="color: #002200;">==</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker setCenter<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>touch locationInView<span style="color: #002200;">:</span>self.view<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cPicker showPicker<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p><a href="https://github.com/sakrist/VBColorPicker" target="_blank"><img src="http://www.developers-life.com/wp-content/uploads/2011/08/github-logo-80px.png" alt="" title="github-logo-80px" width="130" height="80" class="alignnone size-full wp-image-1257" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/color-picker-for-ios.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UIImage and Memory</title>
		<link>http://www.developers-life.com/uiimage-and-memory.html</link>
		<comments>http://www.developers-life.com/uiimage-and-memory.html#comments</comments>
		<pubDate>Thu, 10 Jun 2010 11:43:22 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[UIKit]]></category>
		<category><![CDATA[Ukraine]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1023</guid>
		<description><![CDATA[+[UIImage imageNamed:] • Reads the ﬁle, uncompresses it, caches result • Cached copy of data is kept even if the UIImage is deallocated • Low memory condition causes cache to be purged. • No direct control over when cache is purged. • Use for small frequently drawn images. +[UIImage imageWithContentsOfFile:] • Just reads enough of [...]]]></description>
			<content:encoded><![CDATA[<p>+[UIImage imageNamed:]<br />
• Reads the ﬁle, uncompresses it, caches result<br />
• Cached copy of data is kept even if the UIImage is deallocated<br />
• Low memory condition causes cache to be purged.<br />
• No direct control over when cache is purged.<br />
• Use for small frequently drawn images.</p>
<p>+[UIImage imageWithContentsOfFile:]<br />
• Just reads enough of ﬁle to determine if it can open the ﬁle.<br />
• Reads and uncompresses the ﬁle each time it draws. Uses uncompressed size worth of memory only temporarily.<br />
• Assigning a UIImage created this way to a UIImageView or as the contents of a CALayer also causes it to read and uncompress the ﬁle. The UIImageView or CALayer keep the expanded version.<br />
<span id="more-1023"></span><br />
Memory Usage (in MB) 8.6 MB image used with UIImageView</p>
<table border="0" style="filter:none;font-size:12pt; border: 1px solid;">
<tr>
<td></td>
<td >imageNamed</td>
<td >imageWithContentsofFile</td>
</tr>
<tr>
<td >Initial</td>
<td>2.46</td>
<td>2.46</td>
</tr>
<tr>
<td>Load UIImage</td>
<td>11.12</td>
<td>2.51</td>
</tr>
<tr>
<td>Assign to UIImageView</td>
<td>11.09</td>
<td>11.09</td>
</tr>
<tr>
<td>Remove from UIImageView</td>
<td>11.12</td>
<td>2.51</td>
</tr>
</table>
<p>Memory Usage (in MB) 8.6 MB image used with UIView subclass (stored in instance variable and drawn with drawinRect: )</p>
<table border="0" style="filter:none; border: 1px solid;">
<tbody>
<tr>
<td></td>
<td>imageNamed</td>
<td>imageWithContentsofFile</td>
</tr>
<tr>
<td>Initial</td>
<td>2.73</td>
<td>2.73</td>
</tr>
<tr>
<td>Load UIImage</td>
<td>11.38</td>
<td>2.78</td>
</tr>
<tr>
<td>Assign to UIImageView</td>
<td>11.81</td>
<td>3.20</td>
</tr>
<tr>
<td>Remove from UIImageView</td>
<td>11.84</td>
<td>3.04</td>
</tr>
</tbody>
</table>
<p>Спасибо за некоторые пояснения Андрею Копаневу :)</p>
<p><a href="https://docs.google.com/fileview?id=0B2KSahvz-4DXOTFhM2Y5MzQtODkyZC00N2ExLWE0MWQtNjI2N2NiYTBkNzZh&amp;hl=ru">И вот этому документу</a> &#8211; Robert Clair</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/uiimage-and-memory.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple XML Parser based on NSXMLParser +converter</title>
		<link>http://www.developers-life.com/simple-xml-parser-based-on-nsxmlparser-converter.html</link>
		<comments>http://www.developers-life.com/simple-xml-parser-based-on-nsxmlparser-converter.html#comments</comments>
		<pubDate>Wed, 21 Apr 2010 11:45:16 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=944</guid>
		<description><![CDATA[Simple XML Parser based on NSXMLParser +converter to XML file How To Setup: insert next code to file &#8220;name of you project&#8221;_Prefix.pch 123&#160; &#160; &#160;#import &#34;XMLNode.h&#34; &#160; &#160; &#160;#import &#34;XMLParser.h&#34; &#160; &#160; &#160;#import &#34;XMLConvert.h&#34; Create and launching XMLParser. You will get parsed data ( with XMLNode data type ) in callbackParser: method 12345678&#160; &#160; &#160;NSURL [...]]]></description>
			<content:encoded><![CDATA[<p>Simple XML Parser based on NSXMLParser +converter to XML file</p>
<p>How To Setup:<br />
insert next code to file &#8220;name of you project&#8221;_Prefix.pch</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<span style="color: #6e371a;">#import &quot;XMLNode.h&quot;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #6e371a;">#import &quot;XMLParser.h&quot;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #6e371a;">#import &quot;XMLConvert.h&quot;</span></div></td></tr></tbody></table></div>
<p>Create and launching XMLParser.<br />
You will get parsed data ( with XMLNode data type ) in <em>callbackParser:</em> method</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> <span style="color: #002200;">*</span>URLToFile <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> fileURLWithPath<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> <br />
&nbsp; &nbsp; pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;source&quot;</span> <br />
&nbsp; &nbsp; &nbsp;ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;xml&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;XMLParser <span style="color: #002200;">*</span>parser <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>XMLParser alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>parser setDelegate<span style="color: #002200;">:</span>self withAction<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>callbackParser<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>parser parseXMLFile<span style="color: #002200;">:</span>URLToFile<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>parser release<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Converting results of parsing to XML file:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>content <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>XMLConvert convertXMLNode<span style="color: #002200;">:</span>root<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>And additional define methods for working with XMLNode&#8217;s:<br />
<em>XMLaddAttribute(node, object, key), XMLgetAttribute(node, key), XMLsetParent(node, parent), XMLaddChild(parent, child), XMLgetChild(parent, child), XMLremoveChild(parent, child), XMLgetChildWithAttribute(parent, childname, object, key)</em></p>
<p><a href="http://www.developers-life.com/wp-content/plugins/download_counter/redirect.php?id=9" target="_blank"><img src="http://www.developers-life.com/wp-content/plugins/download_counter/redirect.php?pid=9" border="0" alt="" height="0" width="0" />Source</a><br />
Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/simple-xml-parser-based-on-nsxmlparser-converter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Drag and Drop file on NSImageView</title>
		<link>http://www.developers-life.com/tutorial-drag-and-drop-file-on-nsimageview.html</link>
		<comments>http://www.developers-life.com/tutorial-drag-and-drop-file-on-nsimageview.html#comments</comments>
		<pubDate>Fri, 26 Feb 2010 19:44:07 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[NS]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=906</guid>
		<description><![CDATA[Step by step for starter developers&#8230; 1. Create a project in xCode with name &#8220;DragAndDrop&#8221; or any else&#8230;2. Add an element &#8220;NSImageView&#8221; on main view in the MainMenu.xib 3. Add files NSCImageView.m/NSCImageView.h to project with subclass of UIView 4. Replace &#8220;NSImageView&#8221; name class on &#8220;NSCImageView&#8221; in the NSImageView objec 5.  Change subclass &#8220;NSView&#8221; to &#8220;NSImageView&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Step by step for starter developers&#8230;</p>
<p style="text-align: left;">1. Create a project in xCode with name &#8220;DragAndDrop&#8221; or any else&#8230;<img class="aligncenter" title="create project in xCode" src="http://gyazo.com/9ea3585c0c6a3b480e03fe4ca78ded52.png" alt="" width="312" height="225" />2. Add an element &#8220;NSImageView&#8221; on main view in the MainMenu.xib<a href="http://gyazo.com/efaf33a18871e46e8bc2761227b56a98.png" target="_blank"><img class="aligncenter" title="add an element on xib" src="http://gyazo.com/efaf33a18871e46e8bc2761227b56a98.png" alt="" width="295" height="194" /></a></p>
<p style="text-align: left;"><span id="more-906"></span>3. Add files NSCImageView.m/NSCImageView.h to project with subclass of UIView<a href="http://gyazo.com/5237bf8c7b0c18668f5e06f46547f455.png" target="_blank"><img class="aligncenter" title="add file to project" src="http://gyazo.com/5237bf8c7b0c18668f5e06f46547f455.png" alt="" width="312" height="225" /></a></p>
<p style="text-align: left;">4. Replace &#8220;NSImageView&#8221; name class on &#8220;NSCImageView&#8221; in the NSImageView objec<a href="http://gyazo.com/4e58ec405a87537a97873722dfb89480.png" target="_blank"><img class="aligncenter" src="http://gyazo.com/4e58ec405a87537a97873722dfb89480.png" alt="" width="302" height="219" /></a></p>
<p style="text-align: left;">5.  Change subclass &#8220;NSView&#8221; to &#8220;NSImageView&#8221; <a href="http://gyazo.com/21f607749b9ae6b7ca9db2ed6c70a397.png" target="_blank"><img class="aligncenter" src="http://gyazo.com/21f607749b9ae6b7ca9db2ed6c70a397.png" alt="" width="486" height="80" /></a></p>
<p style="text-align: left;">6. Remove all methods from *.m file<br />
<a href="http://gyazo.com/4a54590860e5a121d455a06b8af9bacd.png" target="_blank"><img class="aligncenter" src="http://gyazo.com/4a54590860e5a121d455a06b8af9bacd.png" alt="" width="307" height="99" /></a></p>
<p style="text-align: left;">7. Methods for getting entering and exit of dragging<br />
<a href="http://gyazo.com/8ed37c3278f48b5e8526136666400cbe.png" target="_blank"><img class="aligncenter" src="http://gyazo.com/8ed37c3278f48b5e8526136666400cbe.png" alt="" width="333" height="242" /></a></p>
<p style="text-align: left;">8. Method for checking information of dragging result<br />
<a href="http://gyazo.com/369f2fe283afda08246f3ddd9b33f10f.png" target="_blank"><img class="aligncenter" src="http://gyazo.com/369f2fe283afda08246f3ddd9b33f10f.png" alt="" width="355" height="513" /></a></p>
<p style="text-align: left;"><a href="http://pastie.org/pastes/844655" target="_blank">Source of NSCImageView.m</a></p>
<p style="text-align: left;"><em>Note: If you make drag and drop with NSView and any other object, you will need add this code: </em></p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">&#91;</span>self registerForDraggedTypes<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> arrayWithObjects<span style="color: #002200;">:</span>NSTIFFPboardType, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NSFilenamesPboardType, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">Result:</p>
<p style="text-align: left;"><a href="http://gyazo.com/4ce91dbd50ae4bf5f6fc640affc375c7.png" target="_blank"><img class="alignleft" src="http://gyazo.com/4ce91dbd50ae4bf5f6fc640affc375c7.png" alt="" width="202" height="166" /></a><a href="http://gyazo.com/c7e0e408f15ecfb7e8395e43c61a40fb.png" target="_blank"><img class="alignnone" src="http://gyazo.com/c7e0e408f15ecfb7e8395e43c61a40fb.png" alt="" width="202" height="166" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/tutorial-drag-and-drop-file-on-nsimageview.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Universal web services suite for iPhone/iPad and Android apps</title>
		<link>http://www.developers-life.com/universal-web-services-suite-for-iphoneipad-and-android-apps.html</link>
		<comments>http://www.developers-life.com/universal-web-services-suite-for-iphoneipad-and-android-apps.html#comments</comments>
		<pubDate>Thu, 25 Feb 2010 12:08:13 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Mob1serv]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Private]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=901</guid>
		<description><![CDATA[Hi there! We are a group of iPhone / Android developers who have developed a suite of web services to assist us and other developers in building great apps. After numerous projects we have become tired of having to set up the server scripts to do all the same things for different clients. Most of [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there! We are a group of iPhone / Android developers who have developed a suite of web services to assist us and other developers in building great apps.</p>
<p>After numerous projects we have become tired of having to set up the server scripts to do all the same things for different clients. Most of the server functionality</p>
<p>is typical: 1) storing location data for Google Maps; 2) storing users&#8217; high scores / ranks; 3) sending Push Notifications; 4) storing files / XML; etc.</p>
<p>We couldn&#8217;t use the existent solutions because in some cases they didn&#8217;t provide the required functionality and in most cases they require your users to be exposed to some social network of theirs, while our clients just want a simple functionality without users knowing of any services behind that.</p>
<p>So we have launched what we call Mob1serv, a universal server solution for the typical needs of iPhone / Android apps. It consists of modules which deal with most common tasks:</p>
<p>    * High Scores &#8211; a powerful online high scores table<br />
    * PushNote &#8211; a module allowing to send immediate or delayed Push Notifications (you can build instant messengers or alarm clocks, anything with this)<br />
    * GeoPos &#8211;  stores locations of Google Map objects, their statuses and &#8216;last seen online&#8217; time<br />
    * OAuth contracter  &#8211; allows you to implement transparent authentication and integration with Facebook, Twitter, Google etc<br />
    * More modules to come!</p>
<p><span id="more-901"></span><br />
We have tried to make it as simple as possible for developers, so you just need to register at the back end and then you can add as many apps as you want and start using these services. From the client (app) side, you need to add a library to your project and put a corresponding ID there, that&#8217;s it.</p>
<p>The service is free, it&#8217;s a &#8216;freemium&#8217; model. It has been built by developers for developers. Some developers and apps are already using it as it was open for alpha testing before, but now we are launching it open for the world so that we can see what you&#8217;re thinking of it and also get your feedback of how we can improve the existent modules or what modules to add next. Welcome to <a href="http://www.mob1serv.com/" title="universal web service for iPhone and Android apps">Mob1serv</a>!</p>
<p><a href="http://www.facebook.com/pages/mob1serv-universal-web-service-for-iPhone-Android/324022903887"><img src="http://gyazo.com/b2486f4d2738f2cb7724d7ebd87321ce.png" title="become our Facebook fan" border="0"></a></p>
<p><a href="https://twitter.com/mob1serv/">Twitter</a></p>
<p><a href="http://www.youtube.com/user/mob1serv">Youtube</a></p>
<p><a href="http://www.vimeo.com/mob1serv">Vimeo</a></p>
<p><a href="http://digg.com/apple/universal_server_API_solution_for_iPhone_Android">Digg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/universal-web-services-suite-for-iphoneipad-and-android-apps.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Matrix of rotate +MozOrientation</title>
		<link>http://www.developers-life.com/use-matrix-of-rotate.html</link>
		<comments>http://www.developers-life.com/use-matrix-of-rotate.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 14:23:12 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[FireFox]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[MozOrientation]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=806</guid>
		<description><![CDATA[Previous post is simple example of usage MozOrientation. But now i use Matrix of rotate and i have nice animation. You can read many information about Matrix of rotate here. These methods are used in game development, make animations and many others. 123456789101112131415161718192021222324252627var context = drawingCanvas.getContext&#40;'2d'&#41;; var xc = 75; var yc = 75; var [...]]]></description>
			<content:encoded><![CDATA[<p>Previous post is simple example of usage MozOrientation. But now i use Matrix of rotate and i have nice animation.</p>
<p>You can read many information about Matrix of rotate <a href="http://ru.wikipedia.org/wiki/%D0%9C%D0%B0%D1%82%D1%80%D0%B8%D1%86%D0%B0_%D0%BF%D0%BE%D0%B2%D0%BE%D1%80%D0%BE%D1%82%D0%B0">here</a>. These methods are used in game development, make animations and many others.</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> context <span style="color: #339933;">=</span> drawingCanvas.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'2d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> xc <span style="color: #339933;">=</span> <span style="color: #CC0000;">75</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> yc <span style="color: #339933;">=</span> <span style="color: #CC0000;">75</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> xi <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> yi <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> myImage <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> angle <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">PI</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*-</span>o.<span style="color: #660066;">x</span><span style="color: #339933;">;</span><br />
myImage.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">clearRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">150</span><span style="color: #339933;">,</span><span style="color: #CC0000;">150</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;xi <span style="color: #339933;">=</span> xi<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>angle<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>yi<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>angle<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>xc<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;yi <span style="color: #339933;">=</span> yi<span style="color: #339933;">*</span>Math.<span style="color: #660066;">sin</span><span style="color: #009900;">&#40;</span>angle<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>yi<span style="color: #339933;">*</span>Math.<span style="color: #660066;">cos</span><span style="color: #009900;">&#40;</span>angle<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>yc<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">translate</span><span style="color: #009900;">&#40;</span> xc <span style="color: #339933;">,</span> yc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">rotate</span><span style="color: #009900;">&#40;</span>angle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">scale</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">+</span>o.<span style="color: #660066;">y</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">+</span>o.<span style="color: #660066;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">drawImage</span><span style="color: #009900;">&#40;</span>myImage<span style="color: #339933;">,</span> xi<span style="color: #339933;">,</span> yi<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;context.<span style="color: #660066;">restore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
myImage.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;feedme.png&quot;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Result:<br />
<canvas id="myDrawing" width="160" height="160">
<p>Your browser doesn&#8217;t support canvas.</p>
<p></canvas><br />
<span id="more-806"></span></p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/1dE_0l7LBJQ&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1dE_0l7LBJQ&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/use-matrix-of-rotate.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resize and Mask an Image</title>
		<link>http://www.developers-life.com/resize-and-mask-an-image.html</link>
		<comments>http://www.developers-life.com/resize-and-mask-an-image.html#comments</comments>
		<pubDate>Sat, 26 Dec 2009 19:37:12 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[Texture]]></category>
		<category><![CDATA[UIKit]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=698</guid>
		<description><![CDATA[Make image with a mask! Source: 123456789101112131415161718192021222324252627282930313233343536373839404142- &#40;UIImage*&#41; maskImage:&#40;UIImage *&#41;image &#160;&#123; &#160; &#160; &#160; &#160; &#160; &#160;CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB&#40;&#41;; &#160; &#160; &#160; &#160; &#160; &#160;UIImage *maskImage = &#91;UIImage imageNamed:@&#34;mask.png&#34;&#93;; &#160; &#160; &#160;CGImageRef maskImageRef = &#91;maskImage CGImage&#93;; &#160; &#160; &#160; &#160; &#160; &#160;// create a bitmap graphics context the size of the image &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Make image with a mask!</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/2id4pPmoCwQ&#038;hl=en_US&#038;fs=1&#038;rel=0&#038;color1=0x3a3a3a&#038;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/2id4pPmoCwQ&#038;hl=en_US&#038;fs=1&#038;rel=0&#038;color1=0x3a3a3a&#038;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
 </p>
<p>Source:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UIImage<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> maskImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>image &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;CGColorSpaceRef colorSpace <span style="color: #002200;">=</span> CGColorSpaceCreateDeviceRGB<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;UIImage <span style="color: #002200;">*</span>maskImage <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;mask.png&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;CGImageRef maskImageRef <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>maskImage CGImage<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// create a bitmap graphics context the size of the image</span><br />
&nbsp; &nbsp; &nbsp;CGContextRef mainViewContentContext <span style="color: #002200;">=</span> CGBitmapContextCreate <span style="color: #002200;">&#40;</span><span style="color: #a61390;">NULL</span>, maskImage.size.width, maskImage.size.height, <span style="color: #2400d9;">8</span>, <span style="color: #2400d9;">0</span>, colorSpace, kCGImageAlphaPremultipliedLast<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>mainViewContentContext<span style="color: #002200;">==</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #a61390;">NULL</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;CGFloat ratio <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;ratio <span style="color: #002200;">=</span> maskImage.size.width<span style="color: #002200;">/</span> image.size.width;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>ratio <span style="color: #002200;">*</span> image.size.height &lt; maskImage.size.height<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ratio <span style="color: #002200;">=</span> maskImage.size.height<span style="color: #002200;">/</span> image.size.height;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;CGRect rect1 &nbsp;<span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span><span style="color: #002200;">&#123;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#125;</span>, <span style="color: #002200;">&#123;</span>maskImage.size.width, maskImage.size.height<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp;CGRect rect2 &nbsp;<span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span><span style="color: #002200;">&#123;</span><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>image.size.width<span style="color: #002200;">*</span>ratio<span style="color: #002200;">&#41;</span><span style="color: #002200;">-</span>maskImage.size.width<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span><span style="color: #2400d9;">2</span> , <span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>image.size.height<span style="color: #002200;">*</span>ratio<span style="color: #002200;">&#41;</span><span style="color: #002200;">-</span>maskImage.size.height<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#125;</span>, <span style="color: #002200;">&#123;</span>image.size.width<span style="color: #002200;">*</span>ratio, image.size.height<span style="color: #002200;">*</span>ratio<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;CGContextClipToMask<span style="color: #002200;">&#40;</span>mainViewContentContext, rect1, maskImageRef<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;CGContextDrawImage<span style="color: #002200;">&#40;</span>mainViewContentContext, rect2, image.CGImage<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Create CGImageRef of the main view bitmap content, and then</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// release that bitmap context</span><br />
&nbsp; &nbsp; &nbsp;CGImageRef newImage <span style="color: #002200;">=</span> CGBitmapContextCreateImage<span style="color: #002200;">&#40;</span>mainViewContentContext<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;CGContextRelease<span style="color: #002200;">&#40;</span>mainViewContentContext<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;UIImage <span style="color: #002200;">*</span>theImage <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageWithCGImage<span style="color: #002200;">:</span>newImage<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;CGImageRelease<span style="color: #002200;">&#40;</span>newImage<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// return the image</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">return</span> theImage;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p></p>
<p><a href="http://depositfiles.com/files/yitpbu87l" style="color:red;">Download Sources of Project</a> </p>
<p><span id="more-698"></span><br />
</p>
<p>Mask:<br />
<img alt="" src="http://gyazo.com/c0be2fb7a12947575d31ecd0fc0ad8da.png" class="alignnone" width="150" height="200" /><br />
<br />
Default image:<br />
<img alt="" src="http://gyazo.com/1d5cfffd9bd81ff423b8dbeb463379f9.png" class="alignnone" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/resize-and-mask-an-image.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>touchBegan/touchEnd in custom UIWebView</title>
		<link>http://www.developers-life.com/touchbegantouchend-in-custom-uiwebview.html</link>
		<comments>http://www.developers-life.com/touchbegantouchend-in-custom-uiwebview.html#comments</comments>
		<pubDate>Sat, 31 Oct 2009 09:56:29 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Private]]></category>
		<category><![CDATA[UIWebView]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Кодинг]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=618</guid>
		<description><![CDATA[The main disadvantage in the object UIWebView is lack of methods touchBegan and touchEnd. But this question has been settled by some manipulations with privates possibilities:) Thank you Satoshi Nakagawa :) PSWebView.h &#8211; empty 1234#import &#60;UIKit/UIKit.h&#62; @interface PSWebView : UIWebView @end If you need add method touchBegan then make step by step 1. add after [...]]]></description>
			<content:encoded><![CDATA[<p>The main disadvantage in the object UIWebView is lack of methods touchBegan and touchEnd. But this question has been settled by some manipulations with privates possibilities:) Thank you Satoshi Nakagawa :)</p>
<p>PSWebView.h &#8211; empty</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span><br />
<br />
<span style="color: #a61390;">@interface</span> PSWebView <span style="color: #002200;">:</span> UIWebView<br />
<span style="color: #a61390;">@end</span></div></td></tr></tbody></table></div>
<p>If you need add method touchBegan then make step by step<br />
1. add after 6 line</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>webView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sender tappedBeganWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;</div></td></tr></tbody></table></div>
<p>2. after 11</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fireBeganTappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;</div></td></tr></tbody></table></div>
<p>3. add after 31</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>__touchesBegan<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches 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<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self __touchesBegan<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">id</span> webView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self superview<span style="color: #002200;">&#93;</span> superview<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>touches.count <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>webView respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>fireBeganTappedWithTouch<span style="color: #002200;">:</span>event<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>webView fireBeganTappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>touches anyObject<span style="color: #002200;">&#93;</span> event<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>4. after 46</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;Method targetMethod2 <span style="color: #002200;">=</span> class_getInstanceMethod<span style="color: #002200;">&#40;</span>klass, <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>touchesBegan<span style="color: #002200;">:</span>withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;Method newMethod2 <span style="color: #002200;">=</span> class_getInstanceMethod<span style="color: #002200;">&#40;</span>klass, <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>__touchesBegan<span style="color: #002200;">:</span>withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;method_exchangeImplementations<span style="color: #002200;">&#40;</span>targetMethod2, newMethod2<span style="color: #002200;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>5. and last addition in source before last &#8220;@end&#8221;</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fireBeganTappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>self.delegate respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>webView<span style="color: #002200;">:</span>tappedBeganWithTouch<span style="color: #002200;">:</span>event<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>self.delegate webView<span style="color: #002200;">:</span>self tappedBeganWithTouch<span style="color: #002200;">:</span>touch event<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>For touchMoves similar steps. It&#8217;s easy!</p>
<p><span id="more-618"></span></p>
<p>PSWebView.m &#8211; all implementation in this file</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6e371a;">#import &lt;objc/runtime.h&gt;</span><br />
<span style="color: #6e371a;">#import &quot;PSWebView.h&quot;</span><br />
<br />
<span style="color: #a61390;">@interface</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> <span style="color: #002200;">&#40;</span>UIWebViewTappingDelegate<span style="color: #002200;">&#41;</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>webView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sender zoomingEndedWithTouches<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>webView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sender tappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;<br />
<span style="color: #a61390;">@end</span><br />
<br />
<span style="color: #a61390;">@interface</span> PSWebView <span style="color: #002200;">&#40;</span>Private<span style="color: #002200;">&#41;</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fireZoomingEndedWithTouches<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fireTappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;<br />
<span style="color: #a61390;">@end</span><br />
<br />
<span style="color: #a61390;">@implementation</span> UIView <span style="color: #002200;">&#40;</span>__TapHook<span style="color: #002200;">&#41;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>__touchesEnded<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches 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<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self __touchesEnded<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">id</span> webView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self superview<span style="color: #002200;">&#93;</span> superview<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>touches.count &gt; <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>webView respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>fireZoomingEndedWithTouches<span style="color: #002200;">:</span>event<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>webView fireZoomingEndedWithTouches<span style="color: #002200;">:</span>touches event<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>webView respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>fireTappedWithTouch<span style="color: #002200;">:</span>event<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>webView fireTappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>touches anyObject<span style="color: #002200;">&#93;</span> event<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@end</span><br />
<br />
<span style="color: #a61390;">static</span> <span style="color: #a61390;">BOOL</span> hookInstalled <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;<br />
<br />
<span style="color: #a61390;">static</span> <span style="color: #a61390;">void</span> installHook<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>hookInstalled<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;hookInstalled <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">Class</span> klass <span style="color: #002200;">=</span> objc_getClass<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;UIWebDocumentView&quot;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;Method targetMethod <span style="color: #002200;">=</span> class_getInstanceMethod<span style="color: #002200;">&#40;</span>klass, <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>touchesEnded<span style="color: #002200;">:</span>withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;Method newMethod <span style="color: #002200;">=</span> class_getInstanceMethod<span style="color: #002200;">&#40;</span>klass, <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>__touchesEnded<span style="color: #002200;">:</span>withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;method_exchangeImplementations<span style="color: #002200;">&#40;</span>targetMethod, newMethod<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@implementation</span> PSWebView<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithCoder<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCoder_Class/"><span style="color: #400080;">NSCoder</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>coder<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <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 initWithCoder<span style="color: #002200;">:</span>coder<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; installHook<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span>frame<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <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>frame<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; installHook<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fireZoomingEndedWithTouches<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>self.delegate respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>webView<span style="color: #002200;">:</span>zoomingEndedWithTouches<span style="color: #002200;">:</span>event<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>self.delegate webView<span style="color: #002200;">:</span>self zoomingEndedWithTouches<span style="color: #002200;">:</span>touches event<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fireTappedWithTouch<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITouch<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touch event<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>self.delegate respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>webView<span style="color: #002200;">:</span>tappedWithTouch<span style="color: #002200;">:</span>event<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>self.delegate webView<span style="color: #002200;">:</span>self tappedWithTouch<span style="color: #002200;">:</span>touch event<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@end</span></div></td></tr></tbody></table></div>
<p><a href="http://depositfiles.com/files/ywlfgsgdf" target="_blank">Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/touchbegantouchend-in-custom-uiwebview.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>UIScrollView and touchesBegan/touchesEnded</title>
		<link>http://www.developers-life.com/uiscrollview-and-touchesbegantouchesended.html</link>
		<comments>http://www.developers-life.com/uiscrollview-and-touchesbegantouchesended.html#comments</comments>
		<pubDate>Wed, 05 Aug 2009 20:27:13 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=518</guid>
		<description><![CDATA[Не работает touchesBegan и touchesEnded в UIScrollView Что делать? Много людей пишет об этой проблеме. Для себя я нашел не совсем стандартное решение. К примеру есть контроллер X в котором наш UIScrollView. в этом же контроллере создадим UIView, но не совсем стандартный, а подготовленный зараннее и передюющий все ивенты  в наш контроллер X и вставим [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Не работает touchesBegan и touchesEnded в UIScrollView<br />
Что делать?</p></blockquote>
<p>Много людей пишет об этой проблеме. Для себя я нашел не совсем стандартное решение. </p>
<p>К примеру есть контроллер X в котором наш UIScrollView. в этом же контроллере создадим UIView, но не совсем стандартный, а подготовленный зараннее и передюющий все ивенты  в наш контроллер X и вставим его в UIScrollView.</p>
<p>К примеру такой код должен содержать подготовленный UIView объект:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touchesBegan<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches 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><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>наш_контроллер_X touchesBegan<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>Как вы будете добираться до своего контроллера X, это уже ваша смекалка.</p>
<p>Может это и велосипед, но думаю есть и более сложные способы :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/uiscrollview-and-touchesbegantouchesended.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Связываем UITableView и UISearchBar</title>
		<link>http://www.developers-life.com/linked-uitableview-and-uisearchbar.html</link>
		<comments>http://www.developers-life.com/linked-uitableview-and-uisearchbar.html#comments</comments>
		<pubDate>Sat, 28 Mar 2009 13:01:11 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=363</guid>
		<description><![CDATA[Опишу как связывал UITableView и UISearchBar. Вот пару примеров: К примеру у нас есть indexArray (NSArray) c объектами NSString. Нужно засунуть этот массив в табличку и связать с поисковой панелью. Прежде рекомендую отсортировать весь массив, т.к. он в UITableView будет отсортирован только по заглавным буквам. 1234567891011121314151617&#160;NSInteger alphabeticSort&#40;id string1, id string2, void *reverse&#41; &#123; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Опишу как связывал UITableView и UISearchBar. Вот пару примеров:</p>
<table border="0">
<tr>
<td>
<img src="http://www.developers-life.com/wp-content/uploads/2009/04/1.png" alt="BNB" width="227" height="429"    /> </td>
<td>  <a href="http://www.injoit.com/eng/portfolio/iphone-applications-portfolio/human-skeleton-iphone-tutorial"><img src="http://www.developers-life.com/wp-content/uploads/2009/04/2.png" alt="Skeleton" width="228" height="427" /></a>
</td>
</tr>
</table>
<p>К примеру у нас есть indexArray (NSArray)  c объектами NSString. Нужно засунуть этот массив в табличку и связать с поисковой панелью.<br />
Прежде рекомендую отсортировать весь массив, т.к. он в UITableView будет отсортирован только по заглавным буквам.</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;NSInteger alphabeticSort<span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> string1, <span style="color: #a61390;">id</span> string2, <span style="color: #a61390;">void</span> <span style="color: #002200;">*</span>reverse<span style="color: #002200;">&#41;</span><br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>NSInteger <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>reverse <span style="color: #002200;">==</span> <span style="color: #a61390;">NO</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>string2 localizedCaseInsensitiveCompare<span style="color: #002200;">:</span>string1<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>string1 localizedCaseInsensitiveCompare<span style="color: #002200;">:</span>string2<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">//Example</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">int</span> reverseSort <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>temp <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>indexArray sortedArrayUsingFunction<span style="color: #002200;">:</span>alphabeticSort context<span style="color: #002200;">:&amp;</span>reverseSort<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>indexArray removeAllObjects<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>indexArray release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;indexArray <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> alloc<span style="color: #002200;">&#93;</span> initWithArray<span style="color: #002200;">:</span>temp<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Так, массив есть отсортированный.<br />
Далее создаем *UIViewController*. Может спросите почему именно такой контроллер :) Отвечу сразу. Мне проще с ним, в нем нету лишнего, лучше вставить свой код. Если чего-то не хватает, то можно всегда открыть документацию в xcode или залесть в тот же framework и прочесть, что есть в том же UITableViewController&#8217;е .</p>
<p><span id="more-363"></span></p>
<p>В UIViewController  <strong>h</strong> файле прописуем:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">@interface</span> IndexController <span style="color: #002200;">:</span> UIViewController &lt;UISearchBarDelegate, UITabBarDelegate, UITableViewDelegate, UITableViewDataSource&gt; <span style="color: #002200;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp;IBOutlet UITableView &nbsp; &nbsp; <span style="color: #002200;">*</span>myTableView;<br />
&nbsp; &nbsp; &nbsp;IBOutlet UISearchBar &nbsp; &nbsp; <span style="color: #002200;">*</span>mySearchBar;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">*</span>listContent;&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// the master content</span><br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> &nbsp; &nbsp; &nbsp;<span style="color: #002200;">*</span>filteredListContent;&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// the filtered content as a result of the search</span><br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> &nbsp; &nbsp; &nbsp;<span style="color: #002200;">*</span>savedContent; &nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// the saved content in case the user cancels a search</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> &nbsp; &nbsp; &nbsp;<span style="color: #002200;">*</span>displayList;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">*</span>indexLetters;<br />
&nbsp; &nbsp; &nbsp;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> UITableView <span style="color: #002200;">*</span>myTableView;<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> UISearchBar <span style="color: #002200;">*</span>mySearchBar;<br />
<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>listContent;<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>filteredListContent;<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>savedContent;<br />
<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>displayList;<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>indexLetters;<br />
<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setUpDisplayList;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setData<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>data;<br />
<br />
<span style="color: #a61390;">@end</span></div></td></tr></tbody></table></div>
<p>В <strong>m</strong> пишем:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br />282<br />283<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//Обязательно</span><br />
<span style="color: #a61390;">@synthesize</span> listContent, filteredListContent, savedContent, myTableView, mySearchBar;<br />
<br />
<span style="color: #a61390;">@synthesize</span> displayList;<br />
<span style="color: #a61390;">@synthesize</span> indexLetters;<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;mySearchBar.autocorrectionType <span style="color: #002200;">=</span> UITextAutocorrectionTypeNo;<br />
&nbsp; &nbsp; &nbsp;mySearchBar.autocapitalizationType <span style="color: #002200;">=</span> UITextAutocapitalizationTypeNone;<br />
&nbsp; &nbsp; &nbsp;mySearchBar.showsCancelButton <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>mySearchBar setTintColor<span style="color: #002200;">:</span>nowColor<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Этим методом вносим наши данные в контроллер</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setData<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>data <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// create the master list</span><br />
&nbsp; &nbsp; &nbsp;listContent <span style="color: #002200;">=</span> data;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>filteredListContent <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>filteredListContent release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;filteredListContent <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> alloc<span style="color: #002200;">&#93;</span> initWithCapacity<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>listContent count<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>filteredListContent addObjectsFromArray<span style="color: #002200;">:</span> listContent<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self setUpDisplayList<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>myTableView reloadData<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Это разделители между списками</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UIView <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView viewForHeaderInSection<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;UILabel<span style="color: #002200;">*</span> hdr <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UILabel alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, tableView.frame.size.width, <span style="color: #2400d9;">14</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;hdr.font <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIFont systemFontOfSize<span style="color: #002200;">:</span><span style="color: #2400d9;">12.0</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;hdr.opaque <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span> ;<br />
&nbsp; &nbsp; &nbsp;hdr.textColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor blackColor<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>sectionDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>displayList objectAtIndex<span style="color: #002200;">:</span>section<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;hdr.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; &nbsp; %@&quot;</span>, <span style="color: #002200;">&#91;</span>sectionDictionary valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;letter&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">return</span> hdr ;<br />
&nbsp; &nbsp; &nbsp;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// В следующих 2 методах за них говорят сами названия, это стандартные, но чтоб не париться с написанием, приведу их</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>numberOfSectionsInTableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Number of sections is the number of region dictionaries</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>filteredListContent count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>displayList count<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #2400d9;">1</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Customize the number of rows in the table view.</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView numberOfRowsInSection<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Number of rows is the number of names in the region dictionary for the specified section</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>filteredListContent count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>letterDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>displayList objectAtIndex<span style="color: #002200;">:</span>section<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>zonesForLetter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>letterDictionary objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;timeZones&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>zonesForLetter count<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Колонка индекса справа</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span> sectionIndexTitlesForTableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; Return the index titles for each of the sections (e.g. &quot;A&quot;, &quot;B&quot;, &quot;C&quot;...).<br />
&nbsp; &nbsp; &nbsp; Use key-value coding to get the value for the key @&quot;letter&quot; in each of the dictionaries in list.<br />
&nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>filteredListContent count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>displayList valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;letter&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView sectionForSectionIndexTitle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>title atIndex<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>index <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Return the index for the given section title</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>filteredListContent count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>indexLetters indexOfObject<span style="color: #002200;">:</span>title<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCellAccessoryType<span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView accessoryTypeForRowWithIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Чтоб не было стрелочек в UITableViewCell</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">return</span> UITableViewCellAccessoryNone;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Собственно сам UITableViewCell</span><br />
<span style="color: #11740a; font-style: italic;">// Customize the appearance of table view cells.</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>MyIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MyIdentifier&quot;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Try to retrieve from the table view a now-unused cell with the given identifier</span><br />
&nbsp; &nbsp; &nbsp;UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>MyIdentifier<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// If no cell is available, create a new one using the given identifier</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span>MyIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// &nbsp;Это мне нужно было когда на UITableViewCell накладывал рисунок с тагом 1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// т.к. &nbsp;cell копируется предыдущий и рисунок остается, а мне нужно без рисунка, вот и очищал так от лишнего</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span> UIImageView <span style="color: #002200;">*</span>view <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>cell subviews<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>view.tag <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>view removeFromSuperview<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;cell.accessoryType <span style="color: #002200;">=</span> UITableViewCellAccessoryDisclosureIndicator;<br />
<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Выборка нужного элемента</span><br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>letterDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>displayList objectAtIndex<span style="color: #002200;">:</span>indexPath.section<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>zonesForLetter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>letterDictionary objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;timeZones&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>timeZoneDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>zonesForLetter objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Set the cell's text to the name of the time zone at the row</span><br />
&nbsp; &nbsp; &nbsp;cell.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>timeZoneDictionary objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;title&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">return</span> cell;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>tableView didSelectRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// Navigation logic may go here. Create and push another view controller.</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@&quot;AnotherView&quot; bundle:nil];</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// [self.navigationController pushViewController:anotherViewController];</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// [anotherViewController release];</span><br />
<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// Собственно при нажатии можно так выбрать, что мы нажали :)</span><br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>letterDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>displayList objectAtIndex<span style="color: #002200;">:</span>indexPath.section<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>zonesForLetter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>letterDictionary objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;timeZones&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>timeZoneDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>zonesForLetter objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Сортировка и ересь :)</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setUpDisplayList <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; Create an array (timeZones) of dictionaries<br />
&nbsp; &nbsp; &nbsp; Each dictionary groups together the time zones with locale names beginning with a particular letter:<br />
&nbsp; &nbsp; &nbsp; key = &quot;letter&quot; value = e.g. &quot;A&quot;<br />
&nbsp; &nbsp; &nbsp; key = &quot;timeZones&quot; value = [array of dictionaries]<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Each dictionary in &quot;timeZones&quot; contains keys &quot;timeZone&quot; and &quot;timeZoneLocaleName&quot;<br />
&nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>filteredListContent count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>displayList count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>displayList removeAllObjects<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span style="color: #400080;">NSMutableDictionary</span></a> <span style="color: #002200;">*</span>indexedTimeZones <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span style="color: #400080;">NSMutableDictionary</span></a> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>name <span style="color: #a61390;">in</span> filteredListContent<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// The region name is unused in this example</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span style="color: #a61390;">strlen</span></a><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>name UTF8String<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>firstLetter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>name substringToIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>indexArray <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>indexedTimeZones objectForKey<span style="color: #002200;">:</span>firstLetter<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>indexArray <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;indexArray <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>indexedTimeZones setObject<span style="color: #002200;">:</span>indexArray forKey<span style="color: #002200;">:</span>firstLetter<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>indexArray release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>timeZoneDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> alloc<span style="color: #002200;">&#93;</span> initWithObjectsAndKeys<span style="color: #002200;">:</span>name, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;title&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>indexArray addObject<span style="color: #002200;">:</span>timeZoneDictionary<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Finish setting up the data structure:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Create the timezones array;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sort the used index letters and keep as an instance variable;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sort the contents of the timeZones arrays;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>timeZones <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// Normally we'd use a localized comparison to present information to the user, but here we know the data only contains unaccented uppercase letters</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.indexLetters <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>indexedTimeZones allKeys<span style="color: #002200;">&#93;</span> sortedArrayUsingSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>compare<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/"><span style="color: #400080;">NSSortDescriptor</span></a> <span style="color: #002200;">*</span>sortDescriptor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/"><span style="color: #400080;">NSSortDescriptor</span></a> alloc<span style="color: #002200;">&#93;</span> initWithKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;timeZoneLocaleName&quot;</span> ascending<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>sortDescriptors <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> arrayWithObject<span style="color: #002200;">:</span>sortDescriptor<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>indexLetter <span style="color: #a61390;">in</span> indexLetters<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>timeZoneDictionaries <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>indexedTimeZones objectForKey<span style="color: #002200;">:</span>indexLetter<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>timeZoneDictionaries sortUsingDescriptors<span style="color: #002200;">:</span>sortDescriptors<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>letterDictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> alloc<span style="color: #002200;">&#93;</span> initWithObjectsAndKeys<span style="color: #002200;">:</span>indexLetter, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;letter&quot;</span>, timeZoneDictionaries, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;timeZones&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>timeZones addObject<span style="color: #002200;">:</span>letterDictionary<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>letterDictionary release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>sortDescriptor release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>indexedTimeZones release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.displayList <span style="color: #002200;">=</span> timeZones;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>timeZones release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #11740a; font-style: italic;">// Это описание нашего сеарч бара</span><br />
&nbsp;<span style="color: #6e371a;">#pragma mark UISearchBarDelegate </span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBarTextDidBeginEditing<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// only show the status bar's cancel button while in edit mode</span><br />
&nbsp; &nbsp; &nbsp;mySearchBar.showsCancelButton <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// flush and save the current list content in case the user cancels the search later</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>savedContent removeAllObjects<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>savedContent addObjectsFromArray<span style="color: #002200;">:</span> filteredListContent<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBarTextDidEndEditing<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;mySearchBar.showsCancelButton <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> reloadDataMyTable<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self setUpDisplayList<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>myTableView reloadData<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBar<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar textDidChange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchText<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>filteredListContent removeAllObjects<span style="color: #002200;">&#93;</span>; <span style="color: #11740a; font-style: italic;">// clear the filtered array first</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// search the table content for cell titles that match &quot;searchText&quot;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// if found add to the mutable array and force the table to reload</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">//</span><br />
&nbsp; &nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>cellTitle;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>cellTitle <span style="color: #a61390;">in</span> listContent<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NSComparisonResult result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>cellTitle compare<span style="color: #002200;">:</span>searchText options<span style="color: #002200;">:</span>NSCaseInsensitiveSearch<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;range<span style="color: #002200;">:</span>NSMakeRange<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #002200;">&#91;</span>searchText length<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>result <span style="color: #002200;">==</span> NSOrderedSame<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>filteredListContent addObject<span style="color: #002200;">:</span>cellTitle<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self reloadDataMyTable<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<br />
<span style="color: #11740a; font-style: italic;">// called when cancel button pressed</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBarCancelButtonClicked<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// if a valid search was entered but the user wanted to cancel, bring back the saved list content</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>searchBar.text.length &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>filteredListContent removeAllObjects<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>filteredListContent addObjectsFromArray<span style="color: #002200;">:</span> savedContent<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>myTableView reloadData<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>searchBar resignFirstResponder<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">//searchBar.text = @&quot;&quot;;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// called when Search (in our case &quot;Done&quot;) button pressed</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBarSearchButtonClicked<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>searchBar resignFirstResponder<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>Создаем xib фаил, кидаем на UIView наши 2 объекта. В File&#8217;s Owner указываем наш контроллер, не забываем связать главную вьюху с контроллером, а потом связуем все что есть в наших объектах с owner&#8217;ром.</p>
<p>Вот, впринципи и все! Если нужно будет как-то разукрасить, то это не проблема, все вспомогательные функции можно посмотреть не выходя из xcode. Рекомендую почаще заглядывать в framework&#8217;и, там есть небольшие комменты, можно и с ними разобраться. </p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/linked-uitableview-and-uisearchbar.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

