<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5819785135863836622</id><updated>2012-01-30T01:27:50.134-08:00</updated><category term='Introduction to iphone developement'/><title type='text'>Dimensions</title><subtitle type='html'>Keeping in mind those numerous blogs that teach you the basics, I have been focusing on special topics only.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-1767109227459993351</id><published>2009-04-28T06:45:00.000-07:00</published><updated>2009-04-28T07:16:50.613-07:00</updated><title type='text'>iPhone Development: Custom Cells</title><content type='html'>Ohhk, quite a lot of things done but this one is something which I have used most often. Custom cells can sometimes greatly push ahead the usability of the application. In this post I am going to create a test project which will demonstrate how to create custom cells and use them appropriately to provide better usability. The application will finally look like this:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SfcJL4OhSYI/AAAAAAAAATE/4debKHb4Aqw/s1600-h/screen-capture.jpg"&gt;                        &lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SfcJL4OhSYI/AAAAAAAAATE/4debKHb4Aqw/s400/screen-capture.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5329738783692769666" style="cursor: pointer; width: 211px; height: 400px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So to start open xcode and create a new project, chose the template as "Navigation Based" and  name it as "CustomCellTestProject". What template you chose does not matter, refer my previous posts to find how you can start working on any template.&lt;/div&gt;&lt;div&gt;First thing we will do is create a customCell. Right click on Classes and add a new UITableViewCell subclass. Name it as "CustomCell". Now open CustomCell.h and add the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#643820;"&gt;#import &lt;/span&gt;&lt;uikit/uikit.h&gt;&lt;/uikit/uikit.h&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span style="color:#aa0d91;"&gt;@interface&lt;/span&gt; CustomCell : UITableViewCell {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UILabel&lt;/span&gt;&lt;span style="color:#000000;"&gt; *&lt;/span&gt;primaryLabel&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UILabel&lt;/span&gt;&lt;span style="color:#000000;"&gt; *&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UIImageView&lt;/span&gt; *myImageView;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;@property&lt;span style="color:#000000;"&gt;(&lt;/span&gt;nonatomic&lt;span style="color:#000000;"&gt;,&lt;/span&gt;retain&lt;span style="color:#000000;"&gt;)&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UILabel&lt;/span&gt;&lt;span style="color:#000000;"&gt; *&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;@property&lt;span style="color:#000000;"&gt;(&lt;/span&gt;nonatomic&lt;span style="color:#000000;"&gt;,&lt;/span&gt;retain&lt;span style="color:#000000;"&gt;)&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UILabel&lt;/span&gt;&lt;span style="color:#000000;"&gt; *&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;secondaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;@property&lt;span style="color:#000000;"&gt;(&lt;/span&gt;nonatomic&lt;span style="color:#000000;"&gt;,&lt;/span&gt;retain&lt;span style="color:#000000;"&gt;)&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UIImageView&lt;/span&gt;&lt;span style="color:#000000;"&gt; *myImageView;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;@end&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(170, 13, 145);  font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here we have simply added a primary label to display the primary text, a secondary label and an imageView. These elements will be created and added into the content view of our custom cell. So open CustomCell.m and add the following code&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;id&lt;/span&gt;)initWithFrame:(&lt;span style="color:#5c2699;"&gt;CGRect&lt;/span&gt;)frame reuseIdentifier:(&lt;span style="color:#5c2699;"&gt;NSString&lt;/span&gt; *)reuseIdentifier {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; (&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt; = [&lt;span style="color:#aa0d91;"&gt;super&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;initWithFrame&lt;/span&gt;:frame &lt;span style="color:#2e0d6e;"&gt;reuseIdentifier&lt;/span&gt;:reuseIdentifier]) {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;        &lt;/span&gt;// Initialization code&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;primaryLabel&lt;span style="color:#000000;"&gt; = [[&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UILabel&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;alloc&lt;/span&gt;&lt;span style="color:#000000;"&gt;]&lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;init&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;.textAlignment = &lt;span style="color:#2e0d6e;"&gt;UITextAlignmentLeft&lt;/span&gt;;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.font = [&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UIFont&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;systemFontOfSize&lt;span style="color:#000000;"&gt;:&lt;/span&gt;&lt;span style="color:#1c00cf;"&gt;14&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt; = [[&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UILabel&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;alloc&lt;/span&gt;&lt;span style="color:#000000;"&gt;]&lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;init&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;secondaryLabel&lt;/span&gt;.textAlignment = &lt;span style="color:#2e0d6e;"&gt;UITextAlignmentLeft&lt;/span&gt;;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;secondaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.font = [&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UIFont&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;systemFontOfSize&lt;span style="color:#000000;"&gt;:&lt;/span&gt;&lt;span style="color:#1c00cf;"&gt;8&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt; = [[&lt;span style="color:#5c2699;"&gt;UIImageView&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;alloc&lt;/span&gt;]&lt;span style="color:#2e0d6e;"&gt;init&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;[&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.contentView &lt;span style="color:#2e0d6e;"&gt;addSubview&lt;/span&gt;:&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;[&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.contentView &lt;span style="color:#2e0d6e;"&gt;addSubview&lt;/span&gt;:&lt;span style="color:#3f6e74;"&gt;secondaryLabel&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;[&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.contentView &lt;span style="color:#2e0d6e;"&gt;addSubview&lt;/span&gt;:&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    }&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;    &lt;/span&gt;return&lt;span style="color:#000000;"&gt; &lt;/span&gt;self&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;We create the three elements and added them to the contentView of our cell. Also don't forget to synthesize all the three elements as we are going to access these elements from other classes.&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span style="color:#aa0d91;"&gt;@synthesize&lt;/span&gt; primaryLabel,secondaryLabel,myImageView;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;Now, we have already added the UI elements into our cell but you must have noticed, we have not yet defined how these elements will appear inside cell. Go ahead and add the following code for that:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)layoutSubviews {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;     [&lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;super&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;layoutSubviews&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGRect&lt;/span&gt; contentRect = &lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.contentView.bounds;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGFloat&lt;/span&gt; boundsX = contentRect.&lt;span style="color:#5c2699;"&gt;origin&lt;/span&gt;.&lt;span style="color:#5c2699;"&gt;x&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGRect&lt;/span&gt; frame;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;frame= &lt;span style="color:#2e0d6e;"&gt;CGRectMake&lt;/span&gt;(boundsX+&lt;span style="color:#1c00cf;"&gt;10&lt;/span&gt; ,&lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;50&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;50&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;.frame = frame;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;frame= &lt;span style="color:#2e0d6e;"&gt;CGRectMake&lt;/span&gt;(boundsX+&lt;span style="color:#1c00cf;"&gt;70&lt;/span&gt; ,&lt;span style="color:#1c00cf;"&gt;5&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;200&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;25&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;.frame = frame;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;frame= &lt;span style="color:#2e0d6e;"&gt;CGRectMake&lt;/span&gt;(boundsX+&lt;span style="color:#1c00cf;"&gt;70&lt;/span&gt; ,&lt;span style="color:#1c00cf;"&gt;30&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;100&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;15&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;secondaryLabel&lt;/span&gt;.frame = frame;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;You can do anything in this method to define the lay out of cell. I have simply assigned frames to all the elements.&lt;/div&gt;&lt;div&gt;You can also find a method in CustomCell.m&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "&gt;- (&lt;span style="color: rgb(170, 13, 145); "&gt;void&lt;/span&gt;)setSelected:(&lt;span style="color: rgb(170, 13, 145); "&gt;BOOL&lt;/span&gt;)selected animated:(&lt;span style="color: rgb(170, 13, 145); "&gt;BOOL&lt;/span&gt;)animated {&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "&gt;    [&lt;span style="color: rgb(170, 13, 145); "&gt;super&lt;/span&gt; &lt;span style="color: rgb(46, 13, 110); "&gt;setSelected&lt;/span&gt;:selected &lt;span style="color: rgb(46, 13, 110); "&gt;animated&lt;/span&gt;:animated];&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;    &lt;/span&gt;// Configure the view for the selected state&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "&gt;}&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This method can be used to define how your cell should react when it is selected. You can describe what should be the highlight color or may be you want to flash one of the labels anything of your choice. I am leaving this method as it is.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We are done with creating our custom cell and now we have to use it. Open RootViewController.m and import CustomCell.h at the top.&lt;/div&gt;&lt;div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span class="Apple-style-span" style="color: rgb(100, 56, 32);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#643820;"&gt;#import &lt;/span&gt;"CustomCell.h"&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am going to create 5 cells here, you can just use your own logic of specifying number of cells and data. So change the following method to look like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#5c2699;"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color:#5c2699;"&gt;UITableView&lt;/span&gt; *)tableView numberOfRowsInSection:(&lt;span style="color:#5c2699;"&gt;NSInteger&lt;/span&gt;)section {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#aa0d91;"&gt;return&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;5&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we are going to use our custom cell. If you look at the cellForRow method, you will find that a UItableViewCell has been created and re used. Now all we have to do is to replace this cell with our new cell. Change the code inside this method to look like this: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#5c2699;"&gt;UITableViewCell&lt;/span&gt; *)tableView:(&lt;span style="color:#5c2699;"&gt;UITableView&lt;/span&gt; *)tableView cellForRowAtIndexPath:(&lt;span style="color:#5c2699;"&gt;NSIndexPath&lt;/span&gt; *)indexPath {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;    &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#aa0d91;"&gt;static&lt;/span&gt; &lt;span style="color:#5c2699;"&gt;NSString&lt;/span&gt; *CellIdentifier = &lt;span style="color:#c41a16;"&gt;@"Cell"&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;    &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#3f6e74;"&gt;CustomCell&lt;/span&gt; *cell = [tableView &lt;span style="color:#2e0d6e;"&gt;dequeueReusableCellWithIdentifier&lt;/span&gt;:CellIdentifier];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; (cell == &lt;span style="color:#aa0d91;"&gt;nil&lt;/span&gt;) {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;        cell = [[[&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;CustomCell&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;alloc&lt;span style="color:#000000;"&gt;] &lt;/span&gt;initWithFrame&lt;span style="color:#000000;"&gt;:&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGRectZero&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;reuseIdentifier&lt;span style="color:#000000;"&gt;:CellIdentifier] &lt;/span&gt;autorelease&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    }&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;    &lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;    &lt;/span&gt;// Set up the cell...&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;switch&lt;/span&gt; (indexPath.row) {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt;:&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;@"Meeting on iPhone Development"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#c41a16;"&gt;@"Sat 10:30"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;.image = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"meeting_color.png"&lt;/span&gt;];&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/span&gt;break&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;:&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;@"Call With Client"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#c41a16;"&gt;@"Planned"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;.image = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"call_color.png"&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;2&lt;/span&gt;:&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;@"Appointment with Joey"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#c41a16;"&gt;@"2 Hours"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;.image = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"calendar_color.png"&lt;/span&gt;];&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/span&gt;break&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;3&lt;/span&gt;:&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;@"Call With Client"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#c41a16;"&gt;@"Planned"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;.image = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"call_color.png"&lt;/span&gt;];&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/span&gt;break&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;4&lt;/span&gt;:&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;primaryLabel&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;@"Appointment with Joey"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;/span&gt;secondaryLabel&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;text&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#c41a16;"&gt;@"2 Hours"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;cell.&lt;span style="color:#3f6e74;"&gt;myImageView&lt;/span&gt;.image = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"calendar_color.png"&lt;/span&gt;];&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/span&gt;break&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;default&lt;span style="color:#000000;"&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/span&gt;break&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#aa0d91;"&gt;return&lt;/span&gt; cell;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;I have added some dummy data. You can use your data source to provide data for primaryLabel and secondaryLabel. Please note that I have used three images here. You can use any image of your choice. All you need to to do is copy the images and paste it into your project root folder (which in this case is CustomCellTestProject folder). After pasting the files, in xcode right click on Resources (or any group), select Add &gt;&gt; ExistingFiles and then select all the images you want to add in you project. Once added you can simply use them by their names.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thats it, go ahead and run the project. You will find something wrong when you compare you simulator screen with mine. If you noticed in the CustomCell.m, I have given some frames to the UI elements. You need to make sure that the height of your cell large enough to accomodate all the elements. So add this following code and you fixed the issue:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;CGFloat&lt;/span&gt;)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView heightForRowAtIndexPath:(&lt;span style="color: #5c2699"&gt;NSIndexPath&lt;/span&gt; *)indexPath&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #1c00cf"&gt;50&lt;/span&gt;&lt;span style="color: #000000"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Let me know if I have been missing something here.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-1767109227459993351?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/1767109227459993351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/04/iphone-development-custom-cells.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/1767109227459993351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/1767109227459993351'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/04/iphone-development-custom-cells.html' title='iPhone Development: Custom Cells'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_pV2VnLyRiRE/SfcJL4OhSYI/AAAAAAAAATE/4debKHb4Aqw/s72-c/screen-capture.jpg' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-1578242356646883902</id><published>2009-04-09T03:37:00.000-07:00</published><updated>2009-04-10T15:33:44.610-07:00</updated><title type='text'>iPhone Development: Creating Native Calendar Like View</title><content type='html'>In this post I will be creating a calendar, which could reused in an any native application.&lt;div&gt;I used the calendar source from &lt;a href="http://tinyurl.com/5k2boy"&gt;here&lt;/a&gt; and modified it a little bit to suit my requirements.&lt;/div&gt;&lt;div&gt;You can find the modified code from my project here: &lt;a href="http://rapidshare.com/files/219229288/CalendarTest.zip"&gt;DOWNLOAD PROJECT&lt;/a&gt;&lt;/div&gt;&lt;div&gt;The final screen should look like this: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd3YIfyCvTI/AAAAAAAAAS8/rdN0UDPpr6M/s1600-h/screen-capture-4.jpg"&gt;                          &lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd3YIfyCvTI/AAAAAAAAAS8/rdN0UDPpr6M/s400/screen-capture-4.jpg" alt="" id="BLOGGER_PHOTO_ID_5322647975103741234" style="cursor: pointer; width: 206px; height: 400px;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can download the complete project from the link given, I will only discuss how we can reuse this calendar and modify it to fit our specific requirements.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open the project CalendarTest in xCode. You will find a folder Calendar containing some 20 files.&lt;/div&gt;&lt;div&gt;You can reuse this folder as such in any project you want show the calendar. I will be using these files to display a modified calendar in CalendarTestView header and implementation files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open CalendarTestView.m and find the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)loadView {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;super&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;loadView&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;calendarView&lt;/span&gt; = [[[&lt;span style="color: rgb(63, 110, 116);"&gt;KLCalendarView&lt;/span&gt; &lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;] &lt;span style="color: rgb(38, 71, 75);"&gt;initWithFrame&lt;/span&gt;:&lt;span style="color: rgb(46, 13, 110);"&gt;CGRectMake&lt;/span&gt;(&lt;span style="color: rgb(28, 0, 207);"&gt;0.0f&lt;/span&gt;, &lt;span style="color: rgb(28, 0, 207);"&gt;0.0f&lt;/span&gt;,  &lt;span style="color: rgb(28, 0, 207);"&gt;320.0f&lt;/span&gt;, &lt;span style="color: rgb(28, 0, 207);"&gt;360&lt;/span&gt;) &lt;span style="color: rgb(38, 71, 75);"&gt;delegate&lt;/span&gt;:&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;] &lt;span style="color: rgb(46, 13, 110);"&gt;autorelease&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;initWithFrame&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;CGRectMake&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;260&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;320&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;160&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) &lt;/span&gt;style&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;UITableViewStylePlain&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;myTableView&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;myTableView&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;delegate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UIView&lt;/span&gt; *myHeaderView = [[&lt;span style="color: rgb(92, 38, 153);"&gt;UIView&lt;/span&gt; &lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;] &lt;span style="color: rgb(46, 13, 110);"&gt;initWithFrame&lt;/span&gt;:&lt;span style="color: rgb(46, 13, 110);"&gt;CGRectMake&lt;/span&gt;(&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;,&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;,&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;.frame.&lt;span style="color: rgb(92, 38, 153);"&gt;size&lt;/span&gt;.&lt;span style="color: rgb(92, 38, 153);"&gt;width&lt;/span&gt; , &lt;span style="color: rgb(28, 0, 207);"&gt;20&lt;/span&gt;)];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;myHeaderView.backgroundColor = [&lt;span style="color: rgb(92, 38, 153);"&gt;UIColor&lt;/span&gt; &lt;span style="color: rgb(46, 13, 110);"&gt;grayColor&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt; &lt;span style="color: rgb(46, 13, 110);"&gt;setTableHeaderView&lt;/span&gt;:myHeaderView];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;.view &lt;span style="color: rgb(46, 13, 110);"&gt;addSubview&lt;/span&gt;:&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.view &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;addSubview&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;calendarView&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.view &lt;/span&gt;bringSubviewToFront&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here I have initialized a tableView and the calendarView with appropriate frames. You can change the frames if you want to change the respective size of tableView and/or calendarView.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now find the Calendar Delegate methods:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)calendarView:(&lt;span style="color: rgb(63, 110, 116);"&gt;KLCalendarView&lt;/span&gt; *)&lt;span style="color: rgb(63, 110, 116);"&gt;calendarView&lt;/span&gt; tappedTile:(&lt;span style="color: rgb(63, 110, 116);"&gt;KLTile&lt;/span&gt; *)aTile{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(196, 26, 22);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;NSLog&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;@"Date Selected is %@"&lt;span style="color: rgb(0, 0, 0);"&gt;,[aTile &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;date&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[aTile &lt;span style="color: rgb(38, 71, 75);"&gt;flash&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt;(&lt;span style="color: rgb(63, 110, 116);"&gt;tile&lt;/span&gt; == &lt;span style="color: rgb(170, 13, 145);"&gt;nil&lt;/span&gt;)&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tile&lt;/span&gt; = aTile;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;else&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(38, 71, 75);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tile&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;restoreBackgroundColor&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tile&lt;/span&gt; = aTile;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here you need to write the code that should be executed when a tile is tapped. Typical usage of this method would be to load data for the tableView from database corresponding to the date of the tile.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(63, 110, 116);"&gt;KLTile&lt;/span&gt; *)calendarView:(&lt;span style="color: rgb(63, 110, 116);"&gt;KLCalendarView&lt;/span&gt; *)&lt;span style="color: rgb(63, 110, 116);"&gt;calendarView&lt;/span&gt; createTileForDate:(&lt;span style="color: rgb(63, 110, 116);"&gt;KLDate&lt;/span&gt; *)date{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;CheckmarkTile&lt;span style="color: rgb(0, 0, 0);"&gt; *&lt;/span&gt;tile&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;CheckmarkTile&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;init&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;//tile.checkmarked = YES;//based on any condition you can checkMark a tile&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tile&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;This method is called for each tile. Just like cellForRow is called for each cell. Please note that although this method will not be called more than once for a tile, but when you change the month of calendar, all tiles are redrawn, so this method will again be called for each tile.&lt;/div&gt;&lt;div&gt;You can find a commented line in this method! This is very important code which you can use to tell the user that they have some data corresponding to a date.&lt;/div&gt;&lt;div&gt;For example I have a meeting on 4th of current month. You can check if tile.date == 4th then check-mark the tile.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)didChangeMonths{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;UIView&lt;/span&gt; *clip = &lt;span style="color: rgb(63, 110, 116);"&gt;calendarView&lt;/span&gt;.superview;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt; (!clip)&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;        &lt;span style="color: rgb(170, 13, 145);"&gt;return&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;    &lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;CGRect&lt;/span&gt; f = clip.frame;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(38, 71, 75);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; weeks = [&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;calendarView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;selectedMonthNumberOfWeeks&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;CGFloat&lt;/span&gt; adjustment = &lt;span style="color: rgb(28, 0, 207);"&gt;0.f&lt;/span&gt;;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;    &lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(170, 13, 145);"&gt;switch&lt;/span&gt; (weeks) {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;        &lt;span style="color: rgb(170, 13, 145);"&gt;case&lt;/span&gt; &lt;span style="color: rgb(28, 0, 207);"&gt;4&lt;/span&gt;:&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            adjustment = (&lt;span style="color: rgb(28, 0, 207);"&gt;92&lt;/span&gt;/&lt;span style="color: rgb(28, 0, 207);"&gt;321&lt;/span&gt;)*&lt;span style="color: rgb(28, 0, 207);"&gt;360&lt;/span&gt;+&lt;span style="color: rgb(28, 0, 207);"&gt;30&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            &lt;span style="color: rgb(170, 13, 145);"&gt;break&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;        &lt;span style="color: rgb(170, 13, 145);"&gt;case&lt;/span&gt; &lt;span style="color: rgb(28, 0, 207);"&gt;5&lt;/span&gt;:&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            adjustment = (&lt;span style="color: rgb(28, 0, 207);"&gt;46&lt;/span&gt;/&lt;span style="color: rgb(28, 0, 207);"&gt;321&lt;/span&gt;)*&lt;span style="color: rgb(28, 0, 207);"&gt;360&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            &lt;span style="color: rgb(170, 13, 145);"&gt;break&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;        &lt;span style="color: rgb(170, 13, 145);"&gt;case&lt;/span&gt; &lt;span style="color: rgb(28, 0, 207);"&gt;6&lt;/span&gt;:&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            adjustment = &lt;span style="color: rgb(28, 0, 207);"&gt;0.f&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            &lt;span style="color: rgb(170, 13, 145);"&gt;break&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;        &lt;span style="color: rgb(170, 13, 145);"&gt;default&lt;/span&gt;:&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;            &lt;span style="color: rgb(170, 13, 145);"&gt;break&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    }&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    f.&lt;span style="color: rgb(92, 38, 153);"&gt;size&lt;/span&gt;.&lt;span style="color: rgb(92, 38, 153);"&gt;height&lt;/span&gt; = &lt;span style="color: rgb(28, 0, 207);"&gt;360&lt;/span&gt; - adjustment;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;    clip.frame = f;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;CGRect&lt;/span&gt; f2 = &lt;span style="color: rgb(46, 13, 110);"&gt;CGRectMake&lt;/span&gt;(&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;,&lt;span style="color: rgb(28, 0, 207);"&gt;260&lt;/span&gt;-adjustment,&lt;span style="color: rgb(28, 0, 207);"&gt;320&lt;/span&gt;,&lt;span style="color: rgb(28, 0, 207);"&gt;160&lt;/span&gt;+adjustment);&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;.frame = f2;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.view &lt;/span&gt;bringSubviewToFront&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tile&lt;/span&gt; = &lt;span style="color: rgb(170, 13, 145);"&gt;nil&lt;/span&gt;;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;This method is called every time you change the month in calendar. I have done some adjustments for fixing the free space between tableView and calendar when there are less number of weeks in a month. You can wrote your own logic for that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now the tableView delegate methods. You can write anything you want depending on your requirement. I have written some dummy code to take screen shots&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(100, 56, 32);"&gt;#pragma mark tableViewDelegate Methods&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;- (&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;)numberOfSectionsInTableView:(&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *)tableView {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;- (&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *)tableView numberOfRowsInSection:(&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;)section {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;5&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;- (&lt;span style="color: rgb(92, 38, 153);"&gt;UITableViewCell&lt;/span&gt; *)tableView:(&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *)tableView cellForRowAtIndexPath:(&lt;span style="color: rgb(92, 38, 153);"&gt;NSIndexPath&lt;/span&gt; *)indexPath {&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *MyIdentifier = &lt;span style="color: rgb(196, 26, 22);"&gt;@"MyIdentifier"&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableViewCell&lt;/span&gt; *cell = [tableView &lt;span style="color: rgb(46, 13, 110);"&gt;dequeueReusableCellWithIdentifier&lt;/span&gt;:MyIdentifier];&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt; (cell == &lt;span style="color: rgb(170, 13, 145);"&gt;nil&lt;/span&gt;) {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;cell = [[[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableViewCell&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0);"&gt;] &lt;/span&gt;initWithFrame&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;CGRectZero&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;reuseIdentifier&lt;span style="color: rgb(0, 0, 0);"&gt;:MyIdentifier] &lt;/span&gt;autorelease&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;accessoryType&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;UITableViewCellAccessoryDisclosureIndicator&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(196, 26, 22);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[cell &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;setText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;@"No Data For Now"&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;return&lt;/span&gt; cell;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;You can read data from the source which maintains data according to the last tile tapped.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let me know if I am missing something.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-1578242356646883902?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://blog.webscale.co.in/?p=244' title='iPhone Development: Creating Native Calendar Like View'/><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/1578242356646883902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/04/iphone-development-creating-native_09.html#comment-form' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/1578242356646883902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/1578242356646883902'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/04/iphone-development-creating-native_09.html' title='iPhone Development: Creating Native Calendar Like View'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd3YIfyCvTI/AAAAAAAAAS8/rdN0UDPpr6M/s72-c/screen-capture-4.jpg' height='72' width='72'/><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-3604468145863639454</id><published>2009-04-09T02:05:00.000-07:00</published><updated>2009-04-09T02:55:12.649-07:00</updated><title type='text'>iPhone Development: Creating Native Contacts like screen</title><content type='html'>Hello again. This time I will be creating a native contacts like screen. If you are not familiar with it, here is how it looks like:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd27wZvaQgI/AAAAAAAAAS0/H04v39kVyl4/s1600-h/screen-capture.jpg"&gt;                         &lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd27wZvaQgI/AAAAAAAAAS0/H04v39kVyl4/s400/screen-capture.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5322616774839648770" style="cursor: pointer; width: 211px; height: 400px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This view is very important for many business applications. There can be several ways of implementing this view, depending upon your specific need you can write one. I will discuss the simplest one in which I will be creating a dictionary to access names. I will be adding code to same DatabaseTest project which I created earlier. &lt;/div&gt;&lt;div&gt;You can find DatabaseTest &lt;a href="http://ved-dimensions.blogspot.com/2009/03/iphone-development-sqlite3-populating.html"&gt;here&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So lets start and open the project DatabaseTest. We need not change anything in AppDelegate. Open RootViewController.h and add the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span style="color: #aa0d91"&gt;@interface&lt;/span&gt; RootViewController : UITableViewController {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;//NSMutableArray *tableData;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSMutableArray&lt;/span&gt; *arrayOfCharacters;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSMutableDictionary&lt;/span&gt; *objectsForCharacters;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;@end&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You will notice that I have commented tableData and declared an additional array and a dictionary. We wont be using tableData anymore instead data will be now stored in dictionary &lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; "&gt;objectsForCharacters. &lt;/span&gt;You will understand how in some time now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open RootViewController.m and in &lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; "&gt;-(&lt;span style="color: #aa0d91"&gt;void&lt;/span&gt;)initializeTableData &lt;/span&gt;comment all the code written and add this code:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;arrayOfCharacters&lt;span style="color: #000000"&gt; = [[&lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSMutableArray&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000"&gt;]&lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;init&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;objectsForCharacters&lt;span style="color: #000000"&gt; = [[&lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSMutableDictionary&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000"&gt;]&lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;init&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;&lt;span style="color: #5c2699"&gt;sqlite3&lt;/span&gt;&lt;span style="color: #000000"&gt; *db = [&lt;/span&gt;DatabaseTestAppDelegate&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #26474b"&gt;getNewDBConnection&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span style="color: #aa0d91"&gt;for&lt;/span&gt;(&lt;span style="color: #aa0d91"&gt;char&lt;/span&gt; c=&lt;span style="color: #1c00cf"&gt;'A'&lt;/span&gt;;c&lt;=&lt;span style="color: #1c00cf"&gt;'Z'&lt;/span&gt;;c++)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #5c2699"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;NSMutableString&lt;span style="color: #000000"&gt; *query;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;query = [&lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSMutableString&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;stringWithFormat&lt;/span&gt;&lt;span style="color: #000000"&gt;:&lt;/span&gt;@"select name from user where name LIKE '%c"&lt;span style="color: #000000"&gt;,c];&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[query &lt;span style="color: #2e0d6e"&gt;appendString&lt;/span&gt;:&lt;span style="color: #c41a16"&gt;@"%'"&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;char&lt;/span&gt; *sql = [query &lt;span style="color: #2e0d6e"&gt;cString&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #5c2699"&gt;sqlite3_stmt&lt;/span&gt; *statement = &lt;span style="color: #aa0d91"&gt;nil&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;if&lt;/span&gt;(&lt;span style="color: #2e0d6e"&gt;sqlite3_prepare_v2&lt;/span&gt;(db,sql, -&lt;span style="color: #1c00cf"&gt;1&lt;/span&gt;, &amp;amp;statement, &lt;span style="color: #aa0d91"&gt;NULL&lt;/span&gt;)!= &lt;span style="color: #643820"&gt;SQLITE_OK&lt;/span&gt;)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #643820"&gt;NSAssert1&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #1c00cf"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;,&lt;/span&gt;@"error preparing statement"&lt;span style="color: #000000"&gt;,&lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;sqlite3_errmsg&lt;/span&gt;&lt;span style="color: #000000"&gt;(db));&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;else&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #5c2699"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;NSMutableArray&lt;span style="color: #000000"&gt; *arrayOfNames = [[&lt;/span&gt;NSMutableArray&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000"&gt;]&lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;init&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;while&lt;/span&gt;(&lt;span style="color: #2e0d6e"&gt;sqlite3_step&lt;/span&gt;(statement)==&lt;span style="color: #643820"&gt;SQLITE_ROW&lt;/span&gt;)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;[arrayOfNames a&lt;/span&gt;ddObject&lt;span style="color: #000000"&gt;:[&lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt;tringWithFormat&lt;span style="color: #000000"&gt;:&lt;/span&gt;&lt;span style="color: #c41a16"&gt;@"%s"&lt;/span&gt;&lt;span style="color: #000000"&gt;,(&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;char&lt;/span&gt;&lt;span style="color: #000000"&gt;*)&lt;/span&gt;sqlite3_column_text&lt;span style="color: #000000"&gt;(statement, &lt;/span&gt;&lt;span style="color: #1c00cf"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)]];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;if&lt;/span&gt;([arrayOfNames &lt;span style="color: #2e0d6e"&gt;count&lt;/span&gt;] &gt;&lt;span style="color: #1c00cf"&gt;0&lt;/span&gt;)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;[arrayOfCharacters &lt;span style="color: #2e0d6e"&gt;addObject&lt;/span&gt;:[&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; &lt;span style="color: #2e0d6e"&gt;stringWithFormat&lt;/span&gt;:&lt;span style="color: #c41a16"&gt;@"%c"&lt;/span&gt;,c]];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;[objectsForCharacters &lt;span style="color: #2e0d6e"&gt;setObject&lt;/span&gt;:arrayOfNames &lt;span style="color: #2e0d6e"&gt;forKey&lt;/span&gt;:[&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; &lt;span style="color: #2e0d6e"&gt;stringWithFormat&lt;/span&gt;:&lt;span style="color: #c41a16"&gt;@"%c"&lt;/span&gt;,c]];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;[arrayOfNames &lt;span style="color: #2e0d6e"&gt;release&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;sqlite3_finalize&lt;span style="color: #000000"&gt;(statement);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;I will explain what we are doing here. For each alphabetical character we are querying database to get all the names starting with that character. If we get 1 more or more names for a character, we add that character in an array arrayOfCharacters. Names are stored in a separate array arrayOfNames. This is a temporary array which will added to dictionary objectsForCharacters. At the end we have arrayOfCharacters holding all those characters which have at least one name starting with them respctively and we have objectsForCharacters holding an array of names for each character in arrayOfCharacters.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we need to fix the view. For this we will now be using 3 new tableView methods:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSArray&lt;/span&gt; *)sectionIndexTitlesForTableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView &lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; "&gt;- (&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView sectionForSectionIndexTitle:(&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; *)title atIndex:(&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)index&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; *)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView titleForHeaderInSection:(&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)section&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;The first method asks for an array of strings which it will use as index titles. You can find indexes A-Z vertically arranged on the rightmost side of tableView. Here you can decide either to give all the characters or just the ones in arrayOfCharacters.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the second method you specify what should be the section number for the given index title.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In third method you provide the title for each section header. You can find in the first figure, a gray bar with a character appearing in it just above each section.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So lets implement these methods, add the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSArray&lt;/span&gt; *)sectionIndexTitlesForTableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #5c2699"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;NSMutableArray&lt;span style="color: #000000"&gt; *toBeReturned = [[&lt;/span&gt;NSMutableArray&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000"&gt;]&lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;init&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;for&lt;/span&gt;(&lt;span style="color: #aa0d91"&gt;char&lt;/span&gt; c = &lt;span style="color: #1c00cf"&gt;'A'&lt;/span&gt;;c&lt;=&lt;span style="color: #1c00cf"&gt;'Z'&lt;/span&gt;;c++)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;[toBeReturned &lt;span style="color: #2e0d6e"&gt;addObject&lt;/span&gt;:[&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; &lt;span style="color: #2e0d6e"&gt;stringWithFormat&lt;/span&gt;:&lt;span style="color: #c41a16"&gt;@"%c"&lt;/span&gt;,c]];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt; toBeReturned;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView sectionForSectionIndexTitle:(&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; *)title atIndex:(&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)index {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt; count = &lt;span style="color: #1c00cf"&gt;0&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;for&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt;&lt;span style="color: #000000"&gt; *character &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;in&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;arrayOfCharacters&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;if&lt;/span&gt;([character &lt;span style="color: #2e0d6e"&gt;isEqualToString&lt;/span&gt;:title])&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt; count;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;count ++;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #1c00cf"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;;&lt;/span&gt;// in case of some eror donot crash d application &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; *)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView titleForHeaderInSection:(&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)section {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt;([&lt;/span&gt;arrayOfCharacters&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;count&lt;/span&gt;&lt;span style="color: #000000"&gt;]==&lt;/span&gt;&lt;span style="color: #1c00cf"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #c41a16"&gt;@""&lt;/span&gt;&lt;span style="color: #000000"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; [&lt;/span&gt;arrayOfCharacters&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;objectAtIndex&lt;/span&gt;&lt;span style="color: #000000"&gt;:section];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;I think I have already explained the code. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before we build and run the project, we need to change the other tableView methods we created last time. Make sure these three methods look like these:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)numberOfSectionsInTableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; [&lt;/span&gt;arrayOfCharacters&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;count&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView numberOfRowsInSection:(&lt;span style="color: #5c2699"&gt;NSInteger&lt;/span&gt;)section {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; [[&lt;/span&gt;objectsForCharacters&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;objectForKey&lt;/span&gt;&lt;span style="color: #000000"&gt;:[&lt;/span&gt;arrayOfCharacters&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;objectAtIndex&lt;/span&gt;&lt;span style="color: #000000"&gt;:section]] &lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;count&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color: #5c2699"&gt;UITableViewCell&lt;/span&gt; *)tableView:(&lt;span style="color: #5c2699"&gt;UITableView&lt;/span&gt; *)tableView cellForRowAtIndexPath:(&lt;span style="color: #5c2699"&gt;NSIndexPath&lt;/span&gt; *)indexPath {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;static&lt;/span&gt; &lt;span style="color: #5c2699"&gt;NSString&lt;/span&gt; *MyIdentifier = &lt;span style="color: #c41a16"&gt;@"MyIdentifier"&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #5c2699"&gt;UITableViewCell&lt;/span&gt; *cell = [tableView &lt;span style="color: #2e0d6e"&gt;dequeueReusableCellWithIdentifier&lt;/span&gt;:MyIdentifier];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;if&lt;/span&gt; (cell == &lt;span style="color: #aa0d91"&gt;nil&lt;/span&gt;) {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;cell = [[[&lt;/span&gt;&lt;span style="color: #5c2699"&gt;UITableViewCell&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;alloc&lt;span style="color: #000000"&gt;] &lt;/span&gt;initWithFrame&lt;span style="color: #000000"&gt;:&lt;/span&gt;&lt;span style="color: #5c2699"&gt;CGRectZero&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;reuseIdentifier&lt;span style="color: #000000"&gt;:MyIdentifier] &lt;/span&gt;autorelease&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;// Set up the cell&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;cell.&lt;/span&gt;&lt;span style="color: #5c2699"&gt;text&lt;/span&gt;&lt;span style="color: #000000"&gt; = [[&lt;/span&gt;&lt;span style="color: #3f6e74"&gt;objectsForCharacters&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;objectForKey&lt;span style="color: #000000"&gt;:[&lt;/span&gt;&lt;span style="color: #3f6e74"&gt;arrayOfCharacters&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;objectAtIndex&lt;span style="color: #000000"&gt;:indexPath.&lt;/span&gt;section&lt;span style="color: #000000"&gt;]] &lt;/span&gt;objectAtIndex&lt;span style="color: #000000"&gt;:indexPath.&lt;/span&gt;row&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #aa0d91"&gt;return&lt;/span&gt; cell;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;I will try explaining a few thing here.    &lt;span class="Apple-style-span" style="color: rgb(63, 110, 116); font-family: Monaco; font-size: 10px; "&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;[[&lt;/span&gt;objectsForCharacters&lt;span style="color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110); "&gt;objectForKey&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;:[&lt;/span&gt;arrayOfCharacters&lt;span style="color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110); "&gt;objectAtIndex&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;:section]] &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110); "&gt;count&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;] &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here we have first derived the character for the section. Then we used that character to obtain its corresponding array of names. And the count of names in the array will be numberOfRows in that section.&lt;/div&gt;&lt;div&gt;Rest should be clear.&lt;/div&gt;&lt;div&gt;Go ahead and run the project and you should see the screen similar to figure 1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also try adding more data into database and see how it looks.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-3604468145863639454?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/3604468145863639454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/04/iphone-development-creating-native.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/3604468145863639454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/3604468145863639454'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/04/iphone-development-creating-native.html' title='iPhone Development: Creating Native Contacts like screen'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd27wZvaQgI/AAAAAAAAAS0/H04v39kVyl4/s72-c/screen-capture.jpg' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-9042092727619363650</id><published>2009-03-03T05:20:00.000-08:00</published><updated>2009-03-30T09:22:24.050-07:00</updated><title type='text'>iPhone Development: SQLite3 - populating table from database</title><content type='html'>In this post I will be discussing how to create and use database on iPhone. The application will finally look like this:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SdDw6mxtEXI/AAAAAAAAASQ/xje1fbZhd-A/s1600-h/screen-capture-2.jpg"&gt;&lt;img style="cursor: pointer; width: 203px; height: 400px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SdDw6mxtEXI/AAAAAAAAASQ/xje1fbZhd-A/s400/screen-capture-2.jpg" alt="" id="BLOGGER_PHOTO_ID_5319016049556656498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So to start, create a new project, chose the template "Navigation Based" and name it as "DatabaseTest". We will be using SQLite3 database and for that we will need the libsqlite framework. Right click on frameworks-&gt;Add Existing. In the search bar type "libsql" and it will show you some 4 frameworks with same name. You have to choose "libsqlite3.0.dylib" whose size is 1.7MB.&lt;br /&gt;&lt;br /&gt;Now we will create a database that we will be importing into our project later. Open the terminal and navigate into your project directory. Execute ls to verify that you are in correct folder. You should see the following screen on your terminal.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa0xuxn-nZI/AAAAAAAAAQw/ONkNVNxSgRY/s1600-h/screen-capture.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 290px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa0xuxn-nZI/AAAAAAAAAQw/ONkNVNxSgRY/s400/screen-capture.jpg" alt="" id="BLOGGER_PHOTO_ID_5308954215404445074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now to create database in your project, type the following command:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;sqlite3 data.sqlite&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;This will create a database with name data.sqlite. Now create a table with name "user" in your database. Execute the following command: sqlite&gt;&lt;span style="font-weight: bold;"&gt; create table user (id varchar(10), name varchar(100));&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we insert some dummy data into the table. Execute following commands:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;sqlite&gt; insert into user values('001','John Mclain');&lt;br /&gt;sqlite&gt; insert into user values('002', 'Joey Triviani');&lt;br /&gt;sqlite&gt; insert into user values('003', 'Spider Man');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Check to see everything went fine.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SdDw5lHyqUI/AAAAAAAAASI/HU_8wJRvLnI/s1600-h/screen-capture-1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 286px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SdDw5lHyqUI/AAAAAAAAASI/HU_8wJRvLnI/s400/screen-capture-1.jpg" alt="" id="BLOGGER_PHOTO_ID_5319016031932557634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now we will import the database into our project. Right click on Resources-&gt;Add-&gt;Existing File and select data.sqlite.&lt;br /&gt;This will add data.sqlite file into Resources folder.&lt;br /&gt;&lt;br /&gt;Now we are ready to write code. Open DatabaseTestAppDelegate.h and import sqlite3.h&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa068EWJ45I/AAAAAAAAARA/0gZr_VQbRsY/s1600-h/screen-capture-2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 170px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa068EWJ45I/AAAAAAAAARA/0gZr_VQbRsY/s400/screen-capture-2.jpg" alt="" id="BLOGGER_PHOTO_ID_5308964339372909458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Open DataBaseTestAppDelegate.m file and add the following code:&lt;br /&gt;&lt;br /&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)createEditableCopyOfDatabaseIfNeeded {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(196, 26, 22);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;NSLog&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;@"Creating editable copy of database"&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;// First, test for existence.&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(170, 13, 145);"&gt;BOOL&lt;/span&gt; success;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;NSFileManager&lt;span style="color: rgb(0, 0, 0);"&gt; *fileManager = [&lt;/span&gt;NSFileManager&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;defaultManager&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;NSError&lt;/span&gt; *error;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *paths = &lt;/span&gt;NSSearchPathForDirectoriesInDomains&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;NSDocumentDirectory&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;NSUserDomainMask&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;YES&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *documentsDirectory = [paths &lt;span style="color: rgb(46, 13, 110);"&gt;objectAtIndex&lt;/span&gt;:&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *writableDBPath = [documentsDirectory &lt;span style="color: rgb(46, 13, 110);"&gt;stringByAppendingPathComponent&lt;/span&gt;:&lt;span style="color: rgb(196, 26, 22);"&gt;@"data.sqlite"&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    success = [fileManager &lt;span style="color: rgb(46, 13, 110);"&gt;fileExistsAtPath&lt;/span&gt;:writableDBPath];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt; (success) &lt;span style="color: rgb(170, 13, 145);"&gt;return&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;// The writable database does not exist, so copy the default to the appropriate location.&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *defaultDBPath = [[[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSBundle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;mainBundle&lt;span style="color: rgb(0, 0, 0);"&gt;] &lt;/span&gt;resourcePath&lt;span style="color: rgb(0, 0, 0);"&gt;] &lt;/span&gt;stringByAppendingPathComponent&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(196, 26, 22);"&gt;@"data.sqlite"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    success = [fileManager &lt;span style="color: rgb(46, 13, 110);"&gt;copyItemAtPath&lt;/span&gt;:defaultDBPath &lt;span style="color: rgb(46, 13, 110);"&gt;toPath&lt;/span&gt;:writableDBPath &lt;span style="color: rgb(46, 13, 110);"&gt;error&lt;/span&gt;:&amp;amp;error];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt; (!success) {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(196, 26, 22);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(100, 56, 32);"&gt;NSAssert1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;@"Failed to create writable database file with message '%@'."&lt;span style="color: rgb(0, 0, 0);"&gt;, [error &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;localizedDescription&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    }&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;We have done nothing but created an editable copy of database into local document. Now add the following code in the same file:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;+(sqlite3 *) getNewDBConnection{&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;sqlite3 *newDBconnection;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *paths = &lt;/span&gt;NSSearchPathForDirectoriesInDomains&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;NSDocumentDirectory&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;NSUserDomainMask&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;YES&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *documentsDirectory = [paths &lt;span style="color: rgb(46, 13, 110);"&gt;objectAtIndex&lt;/span&gt;:&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *path = [documentsDirectory &lt;span style="color: rgb(46, 13, 110);"&gt;stringByAppendingPathComponent&lt;/span&gt;:&lt;span style="color: rgb(196, 26, 22);"&gt;@"data.sqlite"&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;/span&gt;// Open the database. The database was prepared outside the application.&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    &lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt; (sqlite3_open([path &lt;span style="color: rgb(46, 13, 110);"&gt;UTF8String&lt;/span&gt;], &amp;amp;newDBconnection) == SQLITE_OK) {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(196, 26, 22);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;NSLog&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;@"Database Successfully Opened :)"&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;    } &lt;span style="color: rgb(170, 13, 145);"&gt;else&lt;/span&gt; {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(196, 26, 22);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;NSLog&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;@"Error in opening database :("&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;        &lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;    }&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;return&lt;/span&gt; newDBconnection;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt;Here we have created a class method which will be used by other classes to obtain the instance of database. We will see how this will be used in a short while. Mean while in the applicationDidFinishLaunching method add the following code:&lt;br /&gt;&lt;br /&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)applicationDidFinishLaunching:(&lt;span style="color: rgb(92, 38, 153);"&gt;UIApplication&lt;/span&gt; *)application {&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// Configure and show the window&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(38, 71, 75);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;createEditableCopyOfDatabaseIfNeeded&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;window&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;addSubview&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;:[&lt;/span&gt;navigationController&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;view&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;window&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;makeKeyAndVisible&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;So, we have initialized the database. Now we have to use it. For this open RootViewController.h file and add the following code:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa08OS_IxrI/AAAAAAAAARg/jBT1UBNhF_o/s1600-h/screen-capture-9.jpg"&gt;&lt;img style="cursor: pointer; width: 374px; height: 143px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa08OS_IxrI/AAAAAAAAARg/jBT1UBNhF_o/s400/screen-capture-9.jpg" alt="" id="BLOGGER_PHOTO_ID_5308965752052172466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now open RootViewController.m file and add following code:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sa08bso1RtI/AAAAAAAAARo/FTfJGE8Q3nE/s1600-h/screen-capture-6.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 141px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sa08bso1RtI/AAAAAAAAARo/FTfJGE8Q3nE/s400/screen-capture-6.jpg" alt="" id="BLOGGER_PHOTO_ID_5308965982276241106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here we have used the initialize database method to obtain a reference to the database. Using that we created a statement and executed it. Always remember to finalize the statement to avoid unexpected database errors. Now in the viewDidLoad method we will be calling this method. Add the following code:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa088SeQ91I/AAAAAAAAARw/zMgs8KoZ5_k/s1600-h/screen-capture-7.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 99px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/Sa088SeQ91I/AAAAAAAAARw/zMgs8KoZ5_k/s400/screen-capture-7.jpg" alt="" id="BLOGGER_PHOTO_ID_5308966542188279634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So we have read the data from database and also initialized tableData array. Time to display same into the table. Add the following code into the tableView delegate methods:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/Sa09SNr2lxI/AAAAAAAAAR4/coq0vVVtt1s/s1600-h/screen-capture-8.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 181px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/Sa09SNr2lxI/AAAAAAAAAR4/coq0vVVtt1s/s400/screen-capture-8.jpg" alt="" id="BLOGGER_PHOTO_ID_5308966918860216082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There you go! build and run the project and you should get the screen we saw in first image.&lt;br /&gt;I have not covered very basic details, if you still need some I would suggest you to read my previous posts.&lt;br /&gt;In next post I will be showing you how you can edit the table we created and also add new records to it and persist them into database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-9042092727619363650?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/9042092727619363650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/03/iphone-development-sqlite3-populating.html#comment-form' title='45 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/9042092727619363650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/9042092727619363650'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/03/iphone-development-sqlite3-populating.html' title='iPhone Development: SQLite3 - populating table from database'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_pV2VnLyRiRE/SdDw6mxtEXI/AAAAAAAAASQ/xje1fbZhd-A/s72-c/screen-capture-2.jpg' height='72' width='72'/><thr:total>45</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-4497175895468451160</id><published>2009-02-24T02:46:00.000-08:00</published><updated>2009-02-25T02:43:16.892-08:00</updated><title type='text'>iPhone Development: Adding Search Bar in Table View</title><content type='html'>In this post I will be creating a Search screen, which will have a table view with a search bar. Table should display all the records if search field is empty other wise it should show all the records that have matching strings with the search field.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At the end, it should look like this:&lt;/div&gt;&lt;br&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SaPeBLGKp0I/AAAAAAAAAPY/snH8GprK0UY/s1600-h/screen-capture-1.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SaPeBLGKp0I/AAAAAAAAAPY/snH8GprK0UY/s400/screen-capture-1.jpg" alt="" id="BLOGGER_PHOTO_ID_5306328897712465730" style="cursor: pointer; width: 200px; height: 400px;" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SaPeBAOUKCI/AAAAAAAAAPg/HvcDRqXatRE/s1600-h/screen-capture.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SaPeBAOUKCI/AAAAAAAAAPg/HvcDRqXatRE/s400/screen-capture.jpg" alt="" id="BLOGGER_PHOTO_ID_5306328894793852962" style="cursor: pointer; width: 200px; height: 400px;" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So to start create a new ViewBased Project and name it as MySearchScreenApp. You can start with any template you want but you can find in my previous posts why I always start with the most basic template.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Search screen that you can see in the above images are implemented in MySearchScreenAppViewController class. So open the header file MySearchScreenAppViewController.h and add the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;@interface&lt;/span&gt; MySearchScreenAppViewController : UIViewController&lt;uitableviewdatasource,uitableviewdelegate,&gt; {&lt;/uitableviewdatasource,uitableviewdelegate,&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *myTableView;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSMutableArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; &lt;/span&gt;//will be storing all the data&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSMutableArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *tableData;&lt;/span&gt;//will be storing data that will be displayed in table&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSMutableArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *searchedData;&lt;/span&gt;//will be storing data matching with the search string&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *sBar;&lt;/span&gt;//search bar&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;@property&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;nonatomic&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;retain&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSMutableArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; *&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;@end&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we have only defined the UIElements and some data sources. There are three mutable arrays. dataSource will be containing all the data and will be initialized before loading the searchScreen. searchedData will be holding a subset of dataSource based on search string. It will be contents of tableData which you will be viewing in the table below searchBar.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To implement all these elements, open MySearchScreenAppViewController.m file and add the following code in loadView:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)loadView {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;super&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;loadView&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;sBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;initWithFrame&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;CGRectMake&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;320&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;30&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;sBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;delegate&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;.view &lt;span style="color: rgb(46, 13, 110);"&gt;addSubview&lt;/span&gt;:&lt;span style="color: rgb(63, 110, 116);"&gt;sBar&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;initWithFrame&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;CGRectMake&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;300&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;400&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;myTableView&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;delegate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;myTableView&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;span style="color: rgb(170, 13, 145);"&gt;self&lt;/span&gt;.view &lt;span style="color: rgb(46, 13, 110);"&gt;addSubview&lt;/span&gt;:&lt;span style="color: rgb(63, 110, 116);"&gt;myTableView&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;//initialize the two arrays; dataSource will be initialized and populated by appDelegate&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;searchedData&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;NSMutableArray&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;init&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tableData&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;NSMutableArray&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;init&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tableData&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;addObjectsFromArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;//on launch it should display all the records&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;The only code worth explanation here is the last line &lt;span class="Apple-style-span" style="color: rgb(0, 116, 0);font-family:Monaco;font-size:10;"  &gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;tableData&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;addObjectsFromArray&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;As already discussed, dataSource will be holding all of data and tableData will be holding data to be shown in table. This code copies all elements of dataSource into tableData so that when the search screen is visible first time, all the data is displayed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we implement all the tableViewDelegate methods: In the same file add the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;)numberOfSectionsInTableView:(&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *)tableView {&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145); font-family: Monaco; font-size: 10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *)tableView numberOfRowsInSection:(&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt;)section {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;//NSLog(@"contacts error in num of row");&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; [&lt;/span&gt;tableData&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;count&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(92, 38, 153);"&gt;UITableViewCell&lt;/span&gt; *)tableView:(&lt;span style="color: rgb(92, 38, 153);"&gt;UITableView&lt;/span&gt; *)tableView cellForRowAtIndexPath:(&lt;span style="color: rgb(92, 38, 153);"&gt;NSIndexPath&lt;/span&gt; *)indexPath {&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *MyIdentifier = &lt;span style="color: rgb(196, 26, 22);"&gt;@"MyIdentifier"&lt;/span&gt;;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableViewCell&lt;/span&gt; *cell = [tableView &lt;span style="color: rgb(46, 13, 110);"&gt;dequeueReusableCellWithIdentifier&lt;/span&gt;:MyIdentifier];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt; (cell == &lt;span style="color: rgb(170, 13, 145);"&gt;nil&lt;/span&gt;) {&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;cell = [[[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;UITableViewCell&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0);"&gt;] &lt;/span&gt;initWithFrame&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;CGRectZero&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;reuseIdentifier&lt;span style="color: rgb(0, 0, 0);"&gt;:MyIdentifier] &lt;/span&gt;autorelease&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;cell.&lt;span style="color: rgb(92, 38, 153);"&gt;text&lt;/span&gt; = [tableData &lt;span style="color: rgb(46, 13, 110);"&gt;objectAtIndex&lt;/span&gt;:indexPath.&lt;span style="color: rgb(46, 13, 110);"&gt;row&lt;/span&gt;];&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;return&lt;/span&gt; cell;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you do not understand the code above, you should refer  my earlier posts. These methods will be displaying data in tableData array into our table view.&lt;/div&gt;&lt;div&gt;Now we have to implement search bar delegate methods, which will be controlling the contents of tableData. In the same file add the following code:&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(100, 56, 32);"&gt;#pragma mark UISearchBarDelegate&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBarTextDidBeginEditing:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// only show the status bar's cancel button while in edit mode&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;sBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;showsCancelButton&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;YES&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;sBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.autocorrectionType = &lt;/span&gt;UITextAutocorrectionTypeNo&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// flush the previous search content&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[tableData &lt;/span&gt;removeAllObjects&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBarTextDidEndEditing:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;sBar.&lt;/span&gt;showsCancelButton&lt;span style="color: rgb(0, 0, 0);"&gt; = &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;NO&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;In the first method, we are only changing the appearance of search bar when a user taps on search bar. Refer the first two images to find the difference. The main code will be written now:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBar:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar textDidChange:(&lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *)searchText&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[tableData &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;removeAllObjects&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;// remove all data that belongs to previous search&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt;([searchText &lt;span style="color: rgb(46, 13, 110);"&gt;isEqualToString&lt;/span&gt;:&lt;span style="color: rgb(196, 26, 22);"&gt;@""&lt;/span&gt;]||searchText==&lt;span style="color: rgb(170, 13, 145);"&gt;nil&lt;/span&gt;){&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[myTableView &lt;span style="color: rgb(46, 13, 110);"&gt;reloadData&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt; counter = &lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;for&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;NSString&lt;span style="color: rgb(0, 0, 0);"&gt; *name &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;in&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;dataSource&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;NSAutoreleasePool&lt;span style="color: rgb(0, 0, 0);"&gt; *pool = [[&lt;/span&gt;NSAutoreleasePool&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;init&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSRange&lt;/span&gt; r = [name &lt;span style="color: rgb(46, 13, 110);"&gt;rangeOfString&lt;/span&gt;:searchText];&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt;(r.&lt;span style="color: rgb(92, 38, 153);"&gt;location&lt;/span&gt; != &lt;span style="color: rgb(46, 13, 110);"&gt;NSNotFound&lt;/span&gt;)&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(r.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;location&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;//that is we are checking only the start of the names.&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;[tableData &lt;span style="color: rgb(46, 13, 110);"&gt;addObject&lt;/span&gt;:name];&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: Monaco; font-size: 10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;counter++;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[pool &lt;span style="color: rgb(46, 13, 110);"&gt;release&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[myTableView &lt;span style="color: rgb(46, 13, 110);"&gt;reloadData&lt;/span&gt;];&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This method will be called whenever text in the search bar is changed. We should update tableData array accordingly. So the first line&lt;span class="Apple-style-span" style="color: rgb(0, 116, 0);font-family:Monaco;font-size:10;"  &gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[tableData &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;removeAllObjects&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]; &lt;/span&gt;&lt;/span&gt;removes all the searched records from previous search string.&lt;/div&gt;&lt;div&gt;Then we check if the search string is null so that we should return immediately with and empty tableData.&lt;/div&gt;&lt;div&gt;If the searchString is not null then we will go through each object in dataSource and select those objects which have the occurrence of search string in beginning. You can modify the code to have any kind of search though.&lt;/div&gt;&lt;div&gt;The last line&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;[myTableView &lt;span style="color: rgb(46, 13, 110);"&gt;reloadData&lt;/span&gt;]; &lt;/span&gt; refreshes the table view. What ever be the content of tableData will be shown now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We should also show all the records if the search string is cleared or cancelled. For that add the following code:&lt;/div&gt;&lt;div&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBarCancelButtonClicked:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;{&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// if a valid search was entered but the user wanted to cancel, bring back the main list content&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[tableData &lt;/span&gt;removeAllObjects&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[tableData &lt;/span&gt;addObjectsFromArray&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;@try&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[myTableView &lt;span style="color: rgb(46, 13, 110);"&gt;reloadData&lt;/span&gt;];&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;@catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;NSException&lt;span style="color: rgb(0, 0, 0);"&gt; *e){&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[sBar &lt;/span&gt;resignFirstResponder&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;sBar.&lt;span style="color: rgb(92, 38, 153);"&gt;text&lt;/span&gt; = &lt;span style="color: rgb(196, 26, 22);"&gt;@""&lt;/span&gt;;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;}&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p color="#007400" style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;// called when Search (in our case "Done") button pressed&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBarSearchButtonClicked:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:10px;"&gt;{&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[searchBar &lt;/span&gt;resignFirstResponder&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;In the first function, we have flushed all the searched records and simply copy all the records from dataaSource. In the second function we are telling the text pad to resign. You can skip this method to see what happens.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thats it!! We are done with the search screen. But we have to initialize it from AppDelegate. So open MySearchScreenAppAppDelegate.m and add the following code:&lt;/div&gt;&lt;div&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)applicationDidFinishLaunching:(&lt;span style="color: rgb(92, 38, 153);"&gt;UIApplication&lt;/span&gt; *)application {&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// Override point for customization after app launch&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;viewController&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;dataSource&lt;span style="color: rgb(0, 0, 0);"&gt; = [[&lt;/span&gt;NSMutableArray&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;init&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(170, 13, 145);"&gt;char&lt;/span&gt; c = &lt;span style="color: rgb(28, 0, 207);"&gt;'A'&lt;/span&gt;;c&lt;=&lt;span style="color: rgb(28, 0, 207);"&gt;'Z'&lt;/span&gt;;c++)&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;viewController&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;dataSource&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;addObject&lt;span style="color: rgb(0, 0, 0);"&gt;:[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;stringWithFormat&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(196, 26, 22);"&gt;@"%cTestString"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,c]];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;UINavigationController&lt;span style="color: rgb(0, 0, 0);"&gt; *nvc = [[&lt;/span&gt;UINavigationController&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;initWithRootViewController&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;viewController&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(63, 110, 116);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;viewController&lt;span style="color: rgb(0, 0, 0);"&gt;.title = &lt;/span&gt;&lt;span style="color: rgb(196, 26, 22);"&gt;@"Search"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    [&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;window&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;addSubview&lt;span style="color: rgb(0, 0, 0);"&gt;:nvc.&lt;/span&gt;view&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(46, 13, 110);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: rgb(63, 110, 116);"&gt;window&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;makeKeyAndVisible&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Here we have only added dummy data into dataSource to test. You can always store data from database or anywhere .&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now build and run the application. Try typing characters in SearchField, you will find that the search is case sensitive. You will also notice that the search works only if you type the beginning characters only. If you want that the searched records should have search string occurance at any place, here is an alternative implementation of  &lt;span class="Apple-style-span" style=";font-family:Monaco;font-size:10;"  &gt;(&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBarTextDidEndEditing:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar&lt;/span&gt;   &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;- (&lt;span style="color: rgb(170, 13, 145);"&gt;void&lt;/span&gt;)searchBar:(&lt;span style="color: rgb(92, 38, 153);"&gt;UISearchBar&lt;/span&gt; *)searchBar textDidChange:(&lt;span style="color: rgb(92, 38, 153);"&gt;NSString&lt;/span&gt; *)searchText&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;{&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 116, 0);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[tableData &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;removeAllObjects&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;// remove all data that belongs to previous search&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt;([searchText &lt;span style="color: rgb(46, 13, 110);"&gt;isEqualToString&lt;/span&gt;:&lt;span style="color: rgb(196, 26, 22);"&gt;@""&lt;/span&gt;]||searchText==&lt;span style="color: rgb(170, 13, 145);"&gt;nil&lt;/span&gt;){&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[myTableView &lt;span style="color: rgb(46, 13, 110);"&gt;reloadData&lt;/span&gt;];&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(170, 13, 145);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSInteger&lt;/span&gt; counter = &lt;span style="color: rgb(28, 0, 207);"&gt;0&lt;/span&gt;;&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;for&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;NSString&lt;span style="color: rgb(0, 0, 0);"&gt; *name &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;in&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;dataSource&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/p&gt;&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(92, 38, 153);font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;NSAutoreleasePool&lt;span style="color: rgb(0, 0, 0);"&gt; *pool = [[&lt;/span&gt;NSAutoreleasePool&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;alloc&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(46, 13, 110);"&gt;init&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;];&lt;/span&gt;&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: rgb(92, 38, 153);"&gt;NSRange&lt;/span&gt; r = [name &lt;span style="color: rgb(46, 13, 110);"&gt;rangeOfString&lt;/span&gt;:searchText];&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145);"&gt;if&lt;/span&gt;(r.&lt;span style="color: rgb(92, 38, 153);"&gt;location&lt;/span&gt; != &lt;span style="color: rgb(46, 13, 110);"&gt;NSNotFound&lt;/span&gt;)&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;[tableData &lt;span style="color: rgb(46, 13, 110);"&gt;addObject&lt;/span&gt;:name];&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;counter++;&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;[pool &lt;span style="color: rgb(46, 13, 110);"&gt;release&lt;/span&gt;];&lt;/p&gt;&lt;p face="Monaco" size="10px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/p&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;[myTableView &lt;span style="color: rgb(46, 13, 110);"&gt;reloadData&lt;/span&gt;];&lt;/p&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I hope this post was useful. I will suggest you shou should read Predicates to optimize the search if you have very large data source to be searched.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Comments will be appreciated.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-4497175895468451160?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/4497175895468451160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-adding-search-bar-in.html#comment-form' title='30 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4497175895468451160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4497175895468451160'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-adding-search-bar-in.html' title='iPhone Development: Adding Search Bar in Table View'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_pV2VnLyRiRE/SaPeBLGKp0I/AAAAAAAAAPY/snH8GprK0UY/s72-c/screen-capture-1.jpg' height='72' width='72'/><thr:total>30</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-4036399798592763343</id><published>2009-02-04T21:53:00.000-08:00</published><updated>2009-02-24T02:36:53.282-08:00</updated><title type='text'>iPhone Development: Setup Wizard</title><content type='html'>In this post I am going to access all the preferences from the code. Also I have made a setup wizard which allows you to change the preferences from the application it self.&lt;div&gt;Following are some of the things covered:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Reading Preferences&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Editing Preferences&lt;/li&gt;&lt;li&gt;Custom UITableView&lt;/li&gt;&lt;li&gt;Wizard&lt;/li&gt;&lt;/ol&gt;The Wizard will finally look like this:&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqITdgJATI/AAAAAAAAAOM/D8IXNy-6D14/s1600-h/screen-capture-12.jpg"&gt;  &lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqITdgJATI/AAAAAAAAAOM/D8IXNy-6D14/s400/screen-capture-12.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299197779473137970" style="cursor: pointer; width: 205px; height: 400px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;Before we start, lets have a look at NSUserDefaults. This is the class which will be used to access  our preferences. All you need to do is get an instance of this class, after that it is much like a dictionary. For example:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;NSUserDefaults *user = [NSUserDefaults standardUserDefault];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;[user boolForKey:&lt;key&gt;]&lt;/key&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;[user stringForKey:&lt;key&gt;]&lt;/key&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;[user setBool:(BOOL) forKey:&lt;key&gt;] &lt;/key&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So lets start by adding a new UIViewController subclass in the classes folder. Right click on classes and add new UIViewController subclass, name it as SetupWizard.m.&lt;/div&gt;&lt;div&gt;Before accessing preferences, we need to setup the view for the wizard. So open SetupWizard.h and add the following code:&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqDI2ZzWNI/AAAAAAAAANs/w26ba-N6SHM/s1600-h/screen-capture-7.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqDI2ZzWNI/AAAAAAAAANs/w26ba-N6SHM/s400/screen-capture-7.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299192099620739282" style="cursor: pointer; width: 400px; height: 134px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;Here we have created some UI elements which are similar to the ones we have in our application preferences if you remember.&lt;/div&gt;&lt;div&gt;Since we will be using a table view , we have included the tableview delegate and datasource in interface declaration, which also includes &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;UITextFieldDelegate &lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;. We will see later why we have used it.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Also we have made 2 cells, here we are diverting from the conventional coding practices, but there is a reason for that which will be clear as we proceed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For now open SetupWizard.m and add the following code inside loadView method:&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqEsW06sUI/AAAAAAAAAN8/BVe4aHxr66E/s1600-h/screen-capture-1.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqEsW06sUI/AAAAAAAAAN8/BVe4aHxr66E/s400/screen-capture-1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299193809131450690" style="cursor: pointer; width: 380px; height: 400px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;This code is simple enough, just a few UI elements being added on the view. If you are not clear what we did in this code then you need to refer my previous posts. &lt;/div&gt;&lt;div&gt;Important things to note in this code are: we need to have a method named "save" which we have added as a target to the button. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is the method where we will be saving the preferences from our application into the Settings so that next time user launches the application, he has the same preferences he had last time. We will understand that in a while.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before implementing save method, we should not forget we have a tableView added into the view so we have to implement it's protocol methods. Add the following code in SetupWizard.m:&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYqH3zTxekI/AAAAAAAAAOE/7Tr7OQ1FV1c/s1600-h/screen-capture-4.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYqH3zTxekI/AAAAAAAAAOE/7Tr7OQ1FV1c/s400/screen-capture-4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299197304290507330" style="cursor: pointer; width: 400px; height: 285px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;Here we need some description. Why do we need to have 2 cells declared in .h? See the table view in the Wizard image at the beginning of this post. You will notice that this is similar to the one in preferences we made last time. See the image below, it is the multivalue preference we made last time.&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqJvG9nZJI/AAAAAAAAAOU/iqRwUIuWAro/s1600-h/screen-capture-10.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqJvG9nZJI/AAAAAAAAAOU/iqRwUIuWAro/s400/screen-capture-10.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299199353970713746" style="cursor: pointer; width: 198px; height: 400px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;If you tried using it then you must have noticed that when you select a cell, it gets checkmarked and only one cell at a time gets checkmarked. To make this happen in our table view, we had to have the access to both the cells all the time. You will understand this after you see what we are going to write in didSelect method of tableViewDelegate. So go on and write the following code:&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYqK4R3MB6I/AAAAAAAAAOc/XyUrQhewThU/s1600-h/screen-capture-5.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYqK4R3MB6I/AAAAAAAAAOc/XyUrQhewThU/s400/screen-capture-5.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299200611026995106" style="cursor: pointer; width: 400px; height: 121px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;Did that help? If we went on with the conventional coding style, how do we get access to the cell in didSelectMethod to change the accessory types? You will say that I will make a call to cellForRowAtIndexPath and receive the cell where ever I want. That's correct but you only get the cell corresponding to the indexpath you have, if you want to get other cells by this method, you need to create your own index path. Since we had only 2 cells, we can make our lives simple by avoiding  it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we are going to implement the most awaited "Save" method where we will be accessing preferences. Add the following code in SetupWizard.m&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqElK8T9nI/AAAAAAAAAN0/67RK7H5JZQw/s1600-h/screen-capture-2.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqElK8T9nI/AAAAAAAAAN0/67RK7H5JZQw/s400/screen-capture-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5299193685682157170" style="cursor: pointer; width: 400px; height: 183px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I think the code is self explanatory. If you now build the code and run it, you should be expecting to see what you made just now, right? Wrong! you will see the same hello world screen again and the tableview if you pressed the button. What we are going to do now is push this SetupWizard view from an appropriate place. For now, we will be doing it from MyTableView class we created earlier. So open MyTableView.m and add the following code:&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)tableView:(&lt;span style="color:#5c2699;"&gt;UITableView&lt;/span&gt; *)tableView didSelectRowAtIndexPath:(&lt;span style="color:#5c2699;"&gt;NSIndexPath&lt;/span&gt; *)indexPath {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;SetupWizard&lt;span style="color:#000000;"&gt; *wizard = [[&lt;/span&gt;SetupWizard&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;alloc&lt;/span&gt;&lt;span style="color:#000000;"&gt;]&lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;init&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.navigationController &lt;span style="color:#2e0d6e;"&gt;pushViewController&lt;/span&gt;:wizard &lt;span style="color:#2e0d6e;"&gt;animated&lt;/span&gt;:&lt;span style="color:#aa0d91;"&gt;YES&lt;/span&gt;];&lt;/p&gt; &lt;div&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Monaco;font-size:10px;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;Now if you run build and run the project, you can see the wizard by clicking on any row in the table.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;You can download the whole code till now from &lt;/span&gt;&lt;a href="http://rapidshare.com/files/195954874/MyTestProject.zip"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Now, we still have one thing to do. When the user sees the wizard, he should be shown all the previous configurations he chose. For that we will be reading all the preferences and reflecting it in our view. Just add the following code in SetupWizard.m :&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;-(&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)loadPreferences&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#5c2699;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;NSUserDefaults&lt;span style="color:#000000;"&gt; *userDefaults = [&lt;/span&gt;NSUserDefaults&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;standardUserDefaults&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;span style="color:#3f6e74;"&gt;textField&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;setText&lt;/span&gt;: [userDefaults &lt;span style="color:#2e0d6e;"&gt;stringForKey&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"url"&lt;/span&gt;]];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt;([userDefaults &lt;span style="color:#2e0d6e;"&gt;integerForKey&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"whichNumber"&lt;/span&gt;] == &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt;)&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;cell1&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;accessoryType&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;UITableViewCellAccessoryCheckmark&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;else&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;cell2&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;accessoryType&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;UITableViewCellAccessoryCheckmark&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;span style="color:#3f6e74;"&gt;sw&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;setOn&lt;/span&gt;:[userDefaults &lt;span style="color:#2e0d6e;"&gt;boolForKey&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"switch1"&lt;/span&gt;]];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;span style="color:#3f6e74;"&gt;slider&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;setValue&lt;/span&gt;:[userDefaults doubleForKey:&lt;span style="color:#c41a16;"&gt;@"slider_preference"&lt;/span&gt;]];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;`&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and call this method from viewDidLoad like this:&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)viewDidLoad {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#26474b;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;loadPreferences&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt;&lt;div&gt;`&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now if you build and run the application, every time you will see the previous configurations showing up in the wizard.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let me know if I have been missing anything.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-4036399798592763343?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/4036399798592763343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-setup-wizard.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4036399798592763343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4036399798592763343'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-setup-wizard.html' title='iPhone Development: Setup Wizard'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqITdgJATI/AAAAAAAAAOM/D8IXNy-6D14/s72-c/screen-capture-12.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-6460596321095273439</id><published>2009-02-03T06:51:00.000-08:00</published><updated>2009-02-03T08:50:03.635-08:00</updated><title type='text'>iPhone Development: Application Preferences Part 2</title><content type='html'>In this post I will be using PSChildPaneSpecifier in the application preferences.&lt;div&gt;You should read part 1 of this post if you are not familiar with application preferences. You can find it &lt;a href="http://ved-dimensions.blogspot.com/2009/02/iphone-development-application.html"&gt;here&lt;/a&gt; .&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What does PSChildPaneSpecifier do? It adds another page of configurations into your settings. We do that when we have a large number of configurations, so we divide them into categories and make a child pane of each category. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A child pane is nothing but another plist file. So to start with, open the same project "MyTestProject", right click on Settings.bundle and select "add new". From the "Other" tab select plist file as shown below:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYhy-CgVdGI/AAAAAAAAAM0/mKdIH2uP6uk/s1600-h/screen-capture.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYhy-CgVdGI/AAAAAAAAAM0/mKdIH2uP6uk/s400/screen-capture.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298611371751339106" style="cursor: pointer; width: 400px; height: 295px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Name the file as "Child.plist". &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;You will notice that child.plist file is not added in the Settings.bundle. You need to add it inside Settings.bundle which will be done from the terminal.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;To do so, open Terminal and navigate to your projects directory. Execute "ls" on shell to cross verify that you are in the correct directory. Following should appear on the Terminal:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhy-dn_4VI/AAAAAAAAAM8/lM1kabmq3hQ/s1600-h/screen-capture-1.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhy-dn_4VI/AAAAAAAAAM8/lM1kabmq3hQ/s400/screen-capture-1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298611379031236946" style="cursor: pointer; width: 400px; height: 290px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now copy child.plist file into the Settings.bundle by following command: "&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;cp child.plist Settings.bundle&lt;/span&gt;&lt;/span&gt;". Cross verify by navigating into Settings.bundle directory and executing "ls". child.plist file should show up. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Close the terminal now and come to xCode again. You will now find child.plist inside Settings.bundle. Double click Child.plist and add items to make it look like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UnuP2I/AAAAAAAAANE/cjuw9OFlVgg/s1600-h/screen-capture-2.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UnuP2I/AAAAAAAAANE/cjuw9OFlVgg/s400/screen-capture-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298611376614162274" style="cursor: pointer; width: 400px; height: 231px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We have created the new child plist file, now we need to add a reference to it in the root.plist file. Open root.plist and add 2 new items to make it look like this.&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYh0D9h3L4I/AAAAAAAAANc/vKfSAjGj4FY/s1600-h/screen-capture-3.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYh0D9h3L4I/AAAAAAAAANc/vKfSAjGj4FY/s400/screen-capture-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298612573006409602" style="cursor: pointer; width: 400px; height: 185px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Build and run the application , go to the settings and select your project MyTestProject. It shold look similar to the following:&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UemkZI/AAAAAAAAANM/EnJ5CSDVJwM/s1600-h/screen-capture-4.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UemkZI/AAAAAAAAANM/EnJ5CSDVJwM/s400/screen-capture-4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298611376575910290" style="cursor: pointer; width: 197px; height: 400px; " /&gt;   &lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhy-kI0L-I/AAAAAAAAANU/S2UDJFCB640/s1600-h/screen-capture-5.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhy-kI0L-I/AAAAAAAAANU/S2UDJFCB640/s400/screen-capture-5.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298611380779495394" style="cursor: pointer; width: 199px; height: 400px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In next post I am going to access these preferences from the MyTestProject and also allow the user to change them from the View itself.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;`&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-6460596321095273439?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/6460596321095273439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-application_03.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/6460596321095273439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/6460596321095273439'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-application_03.html' title='iPhone Development: Application Preferences Part 2'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_pV2VnLyRiRE/SYhy-CgVdGI/AAAAAAAAAM0/mKdIH2uP6uk/s72-c/screen-capture.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-1979228591740002161</id><published>2009-02-03T05:10:00.000-08:00</published><updated>2009-02-03T08:48:21.781-08:00</updated><title type='text'>iPhone Development: Application Preferences</title><content type='html'>Here I am going to discuss Application Preferences. For those who are unaware of it, Application preferences refers to the configurations that shows up in the Settings. So if you want you application name to be listed inside Settings, you need to follow the procedure.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets first discuss what are the available options. Since we know in iPhone all applications work in a sandbox mode, we can not write a program to alter the behavior of another program. What it means here is, there are fixed UI Elements that can be used in Application preferences, their behavior is also fixed and cannot be changed. For example a you cannot provide a date picker in the settings, you cannot pop up a message saying the URL you entered is not correct. All you can do is provide a field where user can enter his preferences.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Following is a list of options we have for UI elements that we can provide:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;PSTitleValueSpecifier: Used to write titles, similar to UILabel&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;PSTextFieldSpecifier: Similar to UITextField&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;PSToggleSwitchSpecifier: A toggle switch which can be ON or OFF&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;PSSliderSpecifier: A slider which can be used to provide a value bw MAX and MIN&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;PSMultiValueSpecifier: Shows multiple values from which user can select one.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;PSGroupSpecifier: Very important for layout (discussed later).&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;PSChildPaneSpecifier: When you need to have another page of configurations.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;All these elements can be used in the settings and you can read as well as manipulate them from your code.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets start the procedure. Open the same project "MyTestProject" we have been using last time. right click on the resources folder in left pane and select addNew. In the new window select Settings.bundle as shown in the figure.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhUOs4yJOI/AAAAAAAAAMM/D_t8ZeFTk0Q/s1600-h/screen-capture.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhUOs4yJOI/AAAAAAAAAMM/D_t8ZeFTk0Q/s400/screen-capture.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298577573145617634" style="cursor: pointer; width: 400px; height: 298px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Name it as Settings.bundle and click OK. This will create a Settings.bundle in your resources folder. Expand Settings.Bundle and double click on  Root.plist.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;By default it should look like this: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1mAtPI/AAAAAAAAAMk/WNGW6sYcg3E/s1600-h/screen-capture-3.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1mAtPI/AAAAAAAAAMk/WNGW6sYcg3E/s400/screen-capture-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298577575482799346" style="cursor: pointer; width: 400px; height: 140px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Right click on Preference Specifier and select "cut". I did this because in all my tutorials I do not rely on any convenience/ default things provided. It helps later in customizing things the way you want. Any ways now click on the  "+" button on the right side of the table and in place of "new Item" type PreferenceSpecifiers. In the type field corresponding to PreferenceSpecifiers, select "Array".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we will add one by one all the elements we listed earlier. Click on the Arrow symbol to the left of PreferenceSpecifiers to expand it. You will notice that the "+" image on right has now changed and it shows 3 lines. Click on it to add a child which will automatically be named as "Item 1". In the Type select "Dictionary". &lt;/div&gt;&lt;div&gt;Now expand "Item 1" and add a child element to it, name it as "Title". Type should be "String" and in the Value write "URL".&lt;/div&gt;&lt;div&gt;Add more childs and make the plist file look like this:&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUOnvhaPI/AAAAAAAAAMU/5ckfM9-dSbc/s1600-h/screen-capture-1.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUOnvhaPI/AAAAAAAAAMU/5ckfM9-dSbc/s400/screen-capture-1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298577571764594930" style="cursor: pointer; width: 400px; height: 138px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Now Click on the arrow against "Item 1" to hide its child elements, click on "Item 1" (not on the arrow) and click on "+" button on right.&lt;/span&gt; This should show "Item 2" below "Item 1". Follow the last step correctly else you will end up wondering why I am not able to add a child or a new item at the place I want.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Add more items to make it look like this: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhUOxfLvmI/AAAAAAAAAMc/4U8BErBUWHc/s1600-h/screen-capture-2.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhUOxfLvmI/AAAAAAAAAMc/4U8BErBUWHc/s400/screen-capture-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298577574380420706" style="cursor: pointer; width: 400px; height: 305px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now build and run your project, go to Settings and find you applications' name there, clicking on it should show a screen like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1PUtiI/AAAAAAAAAMs/yM2pd2WxU-U/s1600-h/screen-capture-4.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1PUtiI/AAAAAAAAAMs/yM2pd2WxU-U/s400/screen-capture-4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298577575387641378" style="cursor: pointer; width: 213px; height: 400px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have only used three types in the preferences. In next post I will be using PSChildPaneSpecifier and add remaining of the elements i.e. PSTitleViewSpecifier, PSSliderSpecifier and PSGroupSpecifier.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Do not forget to mention name of your project "MyTestProject" against "Title", the second field from top in the pList file. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;A&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;n important thing to remember: "+" button in plist file adds a sibbling and the button with 3 lines adds a child.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you faced any problem in creating child elements or new Items at the specific place in the plist file, don't worry, you just need to expand/hide elements properly. If you still face any problems, lemme know and I will be more than happy to help.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Topics of next post:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Using PSChildPaneSpecifier and adding rest of the types.&lt;/li&gt;&lt;li&gt;Accessing application preferences from inside your code&lt;/li&gt;&lt;li&gt;Changing preferences from your code.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Also in next post we will be creating a custom TableView and custom Cells to display the application preferences in the form of a SetUp Wizard (all by writing code and not using Interface Builder).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-1979228591740002161?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/1979228591740002161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-application.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/1979228591740002161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/1979228591740002161'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/02/iphone-development-application.html' title='iPhone Development: Application Preferences'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhUOs4yJOI/AAAAAAAAAMM/D_t8ZeFTk0Q/s72-c/screen-capture.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-4484076473387169483</id><published>2009-01-20T06:39:00.000-08:00</published><updated>2009-02-03T05:08:01.659-08:00</updated><title type='text'>iPhone Development: Navigating from 1 view to other</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SXcCyyvTK6I/AAAAAAAAALA/kcVgdPmUlN0/s1600-h/screen-capture-7.jpg"&gt;  &lt;img style="cursor:pointer; cursor:hand;width: 169px; height: 320px;" src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SXcCyyvTK6I/AAAAAAAAALA/kcVgdPmUlN0/s320/screen-capture-7.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702958634183586" /&gt;      &lt;/a&gt;&lt;img style="cursor:pointer; cursor:hand;width: 174px; height: 320px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCqlF6rHI/AAAAAAAAAK4/3HtzIUaPgmc/s320/screen-capture-6.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702817531997298" /&gt;&lt;br /&gt;&lt;br /&gt;In this post I will be making another view and tell you how to navigate from first view to the one we are going to create now. Please refer my previous post as I am going to add code to the same project.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, this time we will be creating a complete tableView and populate it with some data. We created a button last time "Hit Me". We will add code so that when user presses it, the new view gets displayed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To start, right click on the classes folder in the left column of your xCode and select add&gt;new file.&lt;/div&gt;&lt;div&gt;Chose the "UIViewController subclass" template and name it as MyTableView. This will add 2 files in the project namely MyTableView.h and MyTableView.m.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now open MyTableView.h and add the follwing code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCR89BsII/AAAAAAAAAKI/60FL3m8NJ1k/s1600-h/screen-capture.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCR89BsII/AAAAAAAAAKI/60FL3m8NJ1k/s320/screen-capture.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702394440429698" style="cursor: pointer; width: 320px; height: 107px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As you can see we have added a UITableView object as a property to this viewController class&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we should create and add this tableView to the view. So open MyTableViewController.m and add the following code to -(void)loadView method.&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCZl1i7AI/AAAAAAAAAKQ/R_x8n1oiMW4/s1600-h/screen-capture-1.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCZl1i7AI/AAAAAAAAAKQ/R_x8n1oiMW4/s320/screen-capture-1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702525673991170" style="cursor: pointer; width: 320px; height: 138px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Most of the lines in code are self explanatory but I will discuss few of them.&lt;/div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"&gt;aTableView&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;delegate&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/p&gt; &lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(63, 110, 116);   font-family:Monaco;font-size:10px;"&gt;aTableView&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;dataSource&lt;/span&gt;&lt;span style="color:#000000;"&gt; = &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;These lines tell that all the delegate methods of tableView will be implemented in this class only. Similarly the data source is set to self.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(63, 110, 116);   font-family:Monaco;font-size:10px;"&gt;&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;&lt;span style="color:#000000;"&gt;.view = &lt;/span&gt;aTableView&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Hmmm..this time we have now added a UI element as a subView as we saw in the last post but instead we are making it the base view it self. I did this because I want the table to cover the whole screen in the application, i.e. I am not going to put any other UI elements so why not make it the base view itself. That ways I dont have to define the frame(coordinates and size of table). I will discuss how to add a table view as a sub view in next post where a table will just be covering a small portion of screen and will have its own scroller.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, we have created a tableView and made it as the base view. But what does this table display? We are now going to do the same thing now. For that we need to implement the delegate methods of UITableView. If you remember the interface definition in MyTableView.h was like &lt;span class="Apple-style-span"   style="  ;font-family:Monaco;font-size:10px;"&gt;&lt;span style="color:#aa0d91;"&gt;@interface&lt;/span&gt; MyTableView : UIViewController &lt;uitableviewdelegate,&gt;{&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;/span&gt;&lt;/uitableviewdelegate,&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;In triangular brackets we tell that what are the protocols that this class will be adhering to.&lt;/div&gt;&lt;div&gt;I just hope you have read ObjC properly to understand what I said.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyways, in the MyTableView.m file add that following code&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXcCqAVNh-I/AAAAAAAAAKY/Gq2pelMEpxU/s1600-h/screen-capture-2.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXcCqAVNh-I/AAAAAAAAAKY/Gq2pelMEpxU/s320/screen-capture-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702807664035810" style="cursor: pointer; width: 320px; height: 237px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, three methods, which are automatically called define how the table will look like and what data it will display.&lt;/div&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "&gt;&lt;span class="Apple-style-span" style="color: rgb(92, 38, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "&gt;&lt;span style="color: rgb(92, 38, 153); "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;UITableViewCell&lt;/span&gt; *cell = [tableView &lt;span style="color: rgb(46, 13, 110); "&gt;dequeueReusableCellWithIdentifier&lt;/span&gt;:MyIdentifier];&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;&lt;span style="color: rgb(170, 13, 145); "&gt;if&lt;/span&gt; (cell == &lt;span style="color: rgb(170, 13, 145); "&gt;nil&lt;/span&gt;) {&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(46, 13, 110);   font-family:Monaco;font-size:10px;"&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;cell  = [[[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153); "&gt;UITableViewCell&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0); "&gt;] &lt;/span&gt;initWithFrame &lt;span style="color: rgb(0, 0, 0); "&gt;:&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153); "&gt;CGRectZero&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt; &lt;/span&gt;reuseIdentifier&lt;span style="color: rgb(0, 0, 0); "&gt;:MyIdentifier]&lt;/span&gt;autorelease&lt;span style="color: rgb(0, 0, 0); "&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;So what is this dequeReusableCell? Why can't we just create a cell by alloc and init? We can do that but there is something you should always keep in mind. This method is called every time you scroll the tableView and a new cell which was not visible earlier gets visible. Imagine you have 20 cells in the table and iPhone can display only 19 on full screen. So the 20th cell will be created by cellForRow method only when it gets visible on the screen. But then the first cell will go out of view ryt? When you scroll back to view the first screen, cellForRow method will be called again to to return a cell to be displayed at first place. That's why we use dequeReusablelCell so that it doesn create a new cell every time.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;CAUTION: Do not do anything stupid inside cellForRow method cuz it gets called multiple times.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;Finally we have created the view and are ready to use it. What we want is that the new view should appear when we click the "Hit Me" button we created earlier. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;So open MyTestProjectViewController.h and modify it to look like this:&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SXcCqIjTSoI/AAAAAAAAAKg/Mia7KtwCbSM/s1600-h/screen-capture-3.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SXcCqIjTSoI/AAAAAAAAAKg/Mia7KtwCbSM/s320/screen-capture-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702809870617218" style="cursor: pointer; width: 320px; height: 142px; " /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;We have only defined an instance of MyTableView  here, to create it and push it on button click&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;open MyTestProjectViewControler.m and modify buttonPressed method we created earlier to look like this:&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCqbpL15I/AAAAAAAAAKo/3hSCiaRpw6k/s1600-h/screen-capture-4.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SXcCqbpL15I/AAAAAAAAAKo/3hSCiaRpw6k/s320/screen-capture-4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293702814995568530" style="cursor: pointer; width: 320px; height: 154px; " /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;Here we are creating an instance of MyTableView and pushing it over the view which we are looking at now.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;If you build this project and run it, you will see the same screen as we saw last time, on pressing the button you will notice that nothing happens. If you chose "navigation based" template when creating the project last time this code would have worked, but since we chose "view based" template its not working. This is the reason why I picked this template so that we can learn how we can programatically do any this we want.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt;The reason why the new view is not getting pushed is that there is no navigationController attached to the originalView. To do so open MyTestProjectAppDelegate.m and find a method named  &lt;span class="Apple-style-span"   style="  ;font-family:Monaco;font-size:10px;"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)applicationDidFinishLaunching:(&lt;span style="color:#5c2699;"&gt;UIApplication&lt;/span&gt; *)application&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:Georgia;font-size:16px;"&gt; Add the code to make it look like this&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhBdxpZMUI/AAAAAAAAAME/av1hXAkBMyo/s1600-h/screen-capture-8.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhBdxpZMUI/AAAAAAAAAME/av1hXAkBMyo/s400/screen-capture-8.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5298556941400355138" style="cursor: pointer; width: 400px; height: 90px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we have created a navigation controller and initialized it with the root view as MyTestProjectViewController. So now our original view has a navigation controller and it can push any view over it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now if you build and run the project, you can see the new screen containing a tableView on pressing the "Hit Me" button.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the next post I will be creating a customized view with a table and a few other UI elements on the same page. This will be my favorite post as I could not find this thing using google.&lt;/div&gt;&lt;div&gt;Also I will be creating App Settings in the same project which will work as dataSource for the new view we will be making.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lemme know if I have been missing something in this post. Till den good luck.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-4484076473387169483?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/4484076473387169483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/01/iphone-development-navigating-from-1.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4484076473387169483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4484076473387169483'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/01/iphone-development-navigating-from-1.html' title='iPhone Development: Navigating from 1 view to other'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_pV2VnLyRiRE/SXcCyyvTK6I/AAAAAAAAALA/kcVgdPmUlN0/s72-c/screen-capture-7.jpg' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-4076741156059608593</id><published>2009-01-20T05:36:00.000-08:00</published><updated>2009-01-20T06:06:56.561-08:00</updated><title type='text'>iPhone Development: Creating a Simple View</title><content type='html'>In this post I will create a simple view with a label and a button. The Label says Hello World and a Button which says Hit Me, when clicked prints a log statement on console.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am going to use this project in all my next posts where I will be building complex views, custom table views with custom cells, animations, webViews etc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The application I am going to build will finally look like this&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SXXUyj7vGDI/AAAAAAAAAJw/b-Z8vvtcoi4/s1600-h/screen-capture-2.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SXXUyj7vGDI/AAAAAAAAAJw/b-Z8vvtcoi4/s320/screen-capture-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293370902148225074" style="cursor: pointer; width: 173px; height: 320px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So open the xCode and create a new project. Chose the template "View Based" and name the project as "MyTestProject"&lt;/div&gt;&lt;div&gt;This will open a new project with may folders appearing on the left side of xCode. Expand the classes folder and select MyTestProjectViewController.h. Add the following code to it:&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXXV3rcJ_kI/AAAAAAAAAJ4/gPZxUlOkTfs/s1600-h/screen-capture-3.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXXV3rcJ_kI/AAAAAAAAAJ4/gPZxUlOkTfs/s320/screen-capture-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293372089574227522" style="cursor: pointer; width: 320px; height: 118px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We have defined a label and a button in the header file. In the implementation file we will create them and finally add it to the baseView. So open MyTestProjectViewController.m and add following code within the implementaion declaration i.e. after&lt;/div&gt;&lt;div&gt;@implementation MyTestProjectViewController.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXXWqHBPsPI/AAAAAAAAAKA/coB3sPcLlCQ/s1600-h/screen-capture-5.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXXWqHBPsPI/AAAAAAAAAKA/coB3sPcLlCQ/s320/screen-capture-5.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293372955971006706" style="cursor: pointer; width: 320px; height: 168px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Most of the lines in code are self explanatory. I will explain some of them:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(46, 13, 110); font-family: Monaco; font-size: 10px; "&gt;&lt;span style="color: rgb(63, 110, 116); "&gt;aLabel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt; = [[&lt;/span&gt;&lt;span style="color: rgb(92, 38, 153); "&gt;UILabel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt; &lt;/span&gt;alloc&lt;span style="color: rgb(0, 0, 0); "&gt;]&lt;/span&gt;initWithFrame&lt;span style="color: rgb(0, 0, 0); "&gt;:&lt;/span&gt;CGRectMake&lt;span style="color: rgb(0, 0, 0); "&gt;(&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207); "&gt;90&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207); "&gt;100&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207); "&gt;200&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;,&lt;/span&gt;&lt;span style="color: rgb(28, 0, 207); "&gt;40&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); "&gt;)];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;here you are actually creating a Label and initializing it with a frame. A frame represents the lay out of a UI element. The first 2 arguments of CGRectMake are (x,y) coordinates from where the label will appear. The last 2 arguments are (width,height) size and they define how much space will they be taking on the view.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(46, 13, 110); font-family: Monaco; font-size: 10px; "&gt;&lt;span style="color: #000000"&gt;[&lt;/span&gt;&lt;span style="color: #3f6e74"&gt;aLabel&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;setBackgroundColor&lt;span style="color: #000000"&gt;:[&lt;/span&gt;&lt;span style="color: #5c2699"&gt;UIColor&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;whiteColor&lt;span style="color: #000000"&gt;]];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Yes a label also has a background color. When you define a frame, you are creating a rectangle with its left corner at the (x,y) and right corner at (x+width, y+height). The label (or any UI element) lies inside a frame. The background color of a label is the color with which this rectangle will be filled.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(46, 13, 110); font-family: Monaco; font-size: 10px; "&gt;&lt;span style="color: #000000"&gt;[&lt;/span&gt;&lt;span style="color: #3f6e74"&gt;aButton&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;addTarget&lt;span style="color: #000000"&gt;:&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;action&lt;span style="color: #000000"&gt;:&lt;/span&gt;&lt;span style="color: #aa0d91"&gt;@selector&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #26474b"&gt;buttonPressed&lt;/span&gt;&lt;span style="color: #000000"&gt;) &lt;/span&gt;forControlEvents&lt;span style="color: #000000"&gt;:&lt;/span&gt;UIControlEventTouchUpInside&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now in this line we are telling what a button should do on being pressed. addTarget:self tells that the event will be handled by the same class in which it is being declared. &lt;/div&gt;&lt;div&gt;action:@selector(buttonPressed) tells that when the button is touchedUPInside this method should be called automatically.&lt;/div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;-(&lt;span style="color: #aa0d91"&gt;void&lt;/span&gt;)buttonPressed&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #2e0d6e"&gt;NSLog&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;@"button was pressed"&lt;span style="color: #000000"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; "&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Finally we have implemented the method which will be called automatically when the button is pressed. You can write anything inside this method.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have not used Interface Builder at all. For me IB is a pain in the as* . If you want to do some serious development you need to learn how every thing is done programatically. In the next post I will be creating another View and add some more Elements to it and we will be adding code for navigating from one view to the other.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let me know if there is any specific issue. &lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"&gt;&lt;span class="Apple-style-span" style="color: rgb(63, 110, 116);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e"&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-4076741156059608593?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/4076741156059608593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/01/iphone-development-creating-simple-view.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4076741156059608593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4076741156059608593'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/01/iphone-development-creating-simple-view.html' title='iPhone Development: Creating a Simple View'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_pV2VnLyRiRE/SXXUyj7vGDI/AAAAAAAAAJw/b-Z8vvtcoi4/s72-c/screen-capture-2.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-4611648280799377864</id><published>2009-01-20T04:49:00.000-08:00</published><updated>2009-01-20T05:16:34.627-08:00</updated><title type='text'>iPhone Development: Customizing HeaderView</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SXXKc13Oe4I/AAAAAAAAAJY/fRLwUVCktWQ/s1600-h/screen-capture-4.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 167px; height: 320px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SXXKc13Oe4I/AAAAAAAAAJY/fRLwUVCktWQ/s320/screen-capture-4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293359533887748994" /&gt;&lt;/a&gt;&lt;br /&gt;This post will discuss how we can add a headerView to a UITableView and customize it.&lt;div&gt;The tableView will finally look like in the above figure. The headerView is the 30 pixel bar just below navigationBar and it reads "Last Synch ..."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;How you make a tableView can be found anywhere on Internet, so I ll assume that you know how to make a tableView.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open the viewController in which you have created your table and add the following code in header file within the interface declaration:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;UIView *myHeaderView;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now open the viewController in which you have created your table and add the following code in implementation file&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXXLUKifUaI/AAAAAAAAAJg/2r2HIH2Vt6A/s1600-h/screen-capture-3.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SXXLUKifUaI/AAAAAAAAAJg/2r2HIH2Vt6A/s320/screen-capture-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5293360484330721698" style="cursor: pointer; width: 320px; height: 126px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have created a method that will create and customize the headerView. You can call this method from viewWillAppear method.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Comments will be appreciated, if you still face any difficulty in creating a headerView, leave a comment and I will be more than happy to address it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-4611648280799377864?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/4611648280799377864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2009/01/iphone-development-customizing.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4611648280799377864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/4611648280799377864'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2009/01/iphone-development-customizing.html' title='iPhone Development: Customizing HeaderView'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_pV2VnLyRiRE/SXXKc13Oe4I/AAAAAAAAAJY/fRLwUVCktWQ/s72-c/screen-capture-4.jpg' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5819785135863836622.post-8933512796732113549</id><published>2008-10-10T12:57:00.000-07:00</published><updated>2008-10-10T17:56:59.913-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Introduction to iphone developement'/><title type='text'>A brief introduction to developement on iPhone</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SO_k1s7wH2I/AAAAAAAAAFI/UWKaW2wWFzg/s1600-h/Picture+5.png"&gt;&lt;img style="margin: 0px auto 10px; text-align: justify; display: block; cursor: pointer;" src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SO_k1s7wH2I/AAAAAAAAAFI/UWKaW2wWFzg/s320/Picture+5.png" alt="" id="BLOGGER_PHOTO_ID_5255670901410635618" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;I joined &lt;a href="http://www.pramati.com/"&gt;Pramati &lt;/a&gt;a month back and on the very first day I was told to inspect&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt; iPhone developement. Sine then I have been &lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;working day and night learning&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; and applying everything I come across. Just few days to go when I will give&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;a complete demonstration of my first application on iPhone. Its a mobile&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;version of Sugar CRM (for those who are unaware of what a CRM is, you can&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;find more about it at &lt;/span&gt;&lt;a href="http://www.sugarcrm.com/"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;http://www.sugarcrm.com&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. And btw CRM stands for&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Customer Relationship Mangement). So in this article I am going to share&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; all my experience, difficulties, things that I liked/ not liked with the &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;developement on iPhone.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;First thing that you should know before you start writing applications on iPhone&lt;br /&gt;is Objective-C. As such its' not a difficult language to learn but there are some&lt;br /&gt;specific features that make it more powerfull and some are just enough to make&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;life as difficult as you can ever imagine.You can find Objective-C tutorials on&lt;br /&gt;&lt;/span&gt;&lt;a href="http://developer.apple.com/iphone"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;http://www.developer.apple.com/iphone&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.As far as my experience says,&lt;br /&gt;understanding these tutorials is really a heck of a job if you are not familiar with&lt;br /&gt;Object-Oriented Programming. They donot teach you obj-c as other books do&lt;br /&gt;it step by step starting from the very core of basics.So it might be frustating when&lt;br /&gt;you are reading it for the first time (and if you have never developed anything on Mac),&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;but once you have given it a quick look, try some hand on example codes given on&lt;br /&gt;the developer site and then read it again. It helped me and only after that I realised&lt;br /&gt;the real power obj-c gives you.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In my examples that I will be posting sooner, you will find how even the minor controls&lt;br /&gt;when taken from the compiler to the run-time can make you code so much powerfull.&lt;br /&gt;But as obvius with great power comes great responsibilities. The compiler in such&lt;br /&gt;cases is lame at reporting some of the absolutely basic mistakes we make at times.&lt;br /&gt;An exapmple of such a situation is when you forget to mention data-type of a&lt;br /&gt;parameter expected by a method. obj-c compiler will not even give you a clue of&lt;br /&gt;what wrong is happening.But good news is if you write your code carefully and in a&lt;br /&gt;structured way, it's a beutifull language to work with.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;" &gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;For all my brothers who are also new to this environment, here are some tips for&lt;br /&gt;getting started with iPhone developement&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Learn the basics of Object Oriented programming(java if you know is very&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;           good, try having a look at "&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;Run-Time Polymorphism&lt;/span&gt;")&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Give a quick look at obj-c (&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;tutorials can be found &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://developer.apple.com/iphone"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;here&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Try playing around with the example code given on developer site of Apple, &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;            write them from scratch, manipulate them, change a few lines and see what happens. &lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Try reading the concepts from the tutorial once again. It gave me a clearer insight of what exactly they mean to do.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;And btw, You need Leopard and XCode to play around with iPhone developement, so get them sooner and have a happy coding and coffee nights :P&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if you are facing any problems on iPhone developement, feel free to leave a comment and I 'll be more then happy to fugure it out for you :)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;font-family:Arial;font-size:13;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5819785135863836622-8933512796732113549?l=ved-dimensions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ved-dimensions.blogspot.com/feeds/8933512796732113549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ved-dimensions.blogspot.com/2008/10/brief-introduction-to-developement-on.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/8933512796732113549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5819785135863836622/posts/default/8933512796732113549'/><link rel='alternate' type='text/html' href='http://ved-dimensions.blogspot.com/2008/10/brief-introduction-to-developement-on.html' title='A brief introduction to developement on iPhone'/><author><name>Ved Surtani</name><uri>http://www.blogger.com/profile/09714144214521232179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_pV2VnLyRiRE/SO_k1s7wH2I/AAAAAAAAAFI/UWKaW2wWFzg/s72-c/Picture+5.png' height='72' width='72'/><thr:total>6</thr:total></entry></feed>
