<?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:blogger='http://schemas.google.com/blogger/2008' 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-7795555183656225888</id><updated>2024-08-30T22:10:31.287+05:30</updated><category term="plist"/><category term="uitableview"/><category term="NSUserDefaults"/><category term="alloc"/><category term="c"/><category term="concepts"/><category term="data"/><category term="delegate"/><category term="delegation"/><category term="design"/><category term="first app"/><category term="interface"/><category term="interface builder"/><category term="ipod"/><category term="memory"/><category term="modal view"/><category term="modalviewcontroller"/><category term="navigation bar"/><category term="objective c"/><category term="objective-c. syntax"/><category term="open source"/><category term="php"/><category term="preferences"/><category term="release"/><category term="save"/><category term="ui"/><category term="uinavigationcontroller"/><category term="uitabbar"/><category term="uitabbarcontroller"/><category term="viewcontroller"/><category term="views"/><category term="xcode"/><title type='text'>iOS development</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.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>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-6733466130040948281</id><published>2011-05-09T18:50:00.013+05:30</published><updated>2011-12-03T00:58:49.527+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="first app"/><category scheme="http://www.blogger.com/atom/ns#" term="interface builder"/><category scheme="http://www.blogger.com/atom/ns#" term="xcode"/><title type='text'>Making your first iPhone app</title><content type='html'>Making your first iPhone app is about getting familiar with the tools and the SDK.&lt;br /&gt;
&lt;br /&gt;
So let us start off, first of all open up XCode and click on new project in the file menu. In the iPhone tab you will be presented with a lot of types of projects, select window based application, click next, name the project myFirstApp.&lt;br /&gt;
&lt;br /&gt;
Now you will have your working environment, i.e Xcode set up with some files with code in it.&lt;br /&gt;
&lt;br /&gt;
iOS development is based on the Model-View-Controller approach, and it involves extensive use of viewControllers. View controllers are classes which draw view on the device&#39;s screen. The class is called UIViewController and most of the times this class will be subclassed to implement your own code. We will also have to do the same. To do this click on new file in the file menu and select the UIViewController subclass, name it FirstViewController and check the options for adding a .h file and a .xib file.&lt;br /&gt;
&lt;br /&gt;
Now to add the view controller add the following code to myFirstAppDelegate.h.&lt;br /&gt;
&lt;br /&gt;
First of all we have to include FirstViewController.h in the appDelegate. You do this by adding the following line on the top of the file&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#import &quot;FirstViewController.h&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now we declare the view controller object in the app delegate. To do this we add the following line inside the @interface brackets&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;FirstViewController *viewController;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;And then after the bracket close we add one more line&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@property (nonatomic, retain) FirstViewController *viewController;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now we move on to the myFirstAppDelegate.m inside the applicationDidFinishLaunching method.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have the basic structure of you app ready, it is time to put in some code. The basic ways of interaction of your user with your apps will be through buttons and labels, let us do that. To do that we will use interface builder, a visual tool to design the interface of your app. The xib file that got added to your project when you created the new view controller subclass is an interface builder file. Double click this file to open up this file in interface builder.&lt;br /&gt;
&lt;br /&gt;
Let us first add a button to the app. To do that search for &#39;UIButton&#39; in the library window and drag it to your view. Resize and name it as you want. Similarly we add a label by searching for &#39;UILabel&#39; in the library window and add it to your view.&lt;br /&gt;
&lt;br /&gt;
Go back to XCode to FirstViewController.h, inside the @interface add declarations for the label. To do this add the following lines&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UILabel *firstLabel;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Outside the brackets add the following lines&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@property (nonatomic,retain) IBOutlet UILabel *firstLabel;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;What the four lines above do it that they tell the app that we have one label. The IBOutlet keyword in the last line is for interface builder to know that there is one label we have declared in our code.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;What we plan to do is to display the number of times the button is pressed on the label. So as an when the button is pressed the count on the label will get incremented by one. To do this we have to call a method whenever the button is pressed and in that method increment the count on the label.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Let us name this method buttonPressed, to tell the app to call the method whenever the button is pressed we need to connect the method and the button through interface builder, but for that we will have to add one line of code in the .h file below the @property line.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-(IBAction)buttonPressed;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This will tell interface builder that this method has been declared in code. Save everything and jump over to interface builder and right click on files owner, you should see the firstLabel you declared, drag the small circle besides the firstLabel to the label in your window/view. This now connects the variable firstLabel to the actual label in the view.&amp;nbsp;&lt;/span&gt;Do the same thing for the method buttonPressed, drag its circle to the button and you should see a list of actions, select the touch up inside action.&lt;br /&gt;
&lt;br /&gt;
With this all your connections are established and the only thing left to do is write the code for incrementing the count. Go to the FirstViewController.m file and add the following line&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@synthesise firstLabel;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This line is to synthesise the property we had added in the FirstViewController.h file. Don&#39;t worry you don&#39;t have to care too much about this right now.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;As you would expect when the app first starts the count should be zero. To do this find the viewDidLoad method in FirstViewController.m and uncomment it. Add the following lines&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;firstLabel.text = [NSString stringWithFormat:@&quot;%d&quot;,0];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Now to&amp;nbsp;&lt;/span&gt;implement&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;the method buttonPressed.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-(IBAction)buttonPressed&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; NSInteger num = [firstLabel.text intValue];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; num++;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; firstLabel.text = [NSString stringWithString:@&quot;%d&quot;,num];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Save everything and build the project. If everything goes well you will have your app running!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In an extension to this tutorial we will add code to the existing app that will save state, i.e the count so that when you open the app again after closing the count gets retrieved.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/6733466130040948281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/6733466130040948281' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/6733466130040948281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/6733466130040948281'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/05/making-your-first-iphone-app.html' title='Making your first iPhone app'/><author><name>Rounak</name><uri>http://www.blogger.com/profile/02439031547879761846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-6698523179679651554</id><published>2011-05-09T03:20:00.000+05:30</published><updated>2011-05-09T03:20:31.843+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="modal view"/><category scheme="http://www.blogger.com/atom/ns#" term="modalviewcontroller"/><category scheme="http://www.blogger.com/atom/ns#" term="views"/><title type='text'>Modal Views</title><content type='html'>Many apps that require the user to sign in present a view sliding up from the bottom of the screen, this is called a modal view. Sliding-up is just one way a modal view can be presented, other ways are partial curl like in the maps app, the flipping view when you tap the &#39;i&#39; button etc.&lt;div&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL2ZSDNjTftXW8tHcyeI_1Kq1dpKJE92F0WbMSgj8u8RZ9h3EnhuNJ3-tbwUzTtZjziniNavHQ8OqQGcNzNuu6Jncvk-sKPHy9ChRpSCCP7nvL-ALGdGDAHMf7GZYfTXfRtVHjv8_gBkEE/s1600/P88845801.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL2ZSDNjTftXW8tHcyeI_1Kq1dpKJE92F0WbMSgj8u8RZ9h3EnhuNJ3-tbwUzTtZjziniNavHQ8OqQGcNzNuu6Jncvk-sKPHy9ChRpSCCP7nvL-ALGdGDAHMf7GZYfTXfRtVHjv8_gBkEE/s320/P88845801.jpg&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Partial curl in maps&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;So the idea of a modal view is to present a temporary view which asks the user to perform some action and then the view is dismissed to reveal the original view. The idea of a sign in perfectly fits into the reason of a modal view being presented, the user is doing something that requires signing in, the modal view is presented, the user logs in and the original screen comes back to let the user continue his/her activity in the app.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;So let us get to know how is this done in code. First you&#39;ll need two view controllers, one will be the main view and the second will be the modal view. Set up the first view controller to have a button which is hooked up to a method called buttonPressed. In this method put the following code to present the second view modally.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;SecondView *modalViewController = [[SecondView alloc] init];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[modalViewController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[self presentModalViewController:modalViewController animated:YES];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If everything goes well when you build the app and press the button, a new view should slide from below.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;To make the view appear in other styles like horizontal flip use the following pass the following parameters instead of&amp;nbsp;UIModalTransitionStyleCoverVertical&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Horizontal flip -&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;UIModalTransitionStyleFlipHorizontal&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;Partial curl - &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;UIModalTransitionStylePartialCurl&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Dissolve - &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666; font-family: Courier, Consolas, monospace; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-family: inherit;&quot;&gt;UIModalTransitionStyleCrossDissolve&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;Try running the project with each of these as arguments to have a look at all the animations.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now that we have&amp;nbsp;&lt;/span&gt;successfully managed to present view controllers, we move on to dismissing them, that is bring back the original view on the screen from where the modal view was presented.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;For this add a button in your secondView which hooks up to a method, lets call it otherButtonPressed. Include the following code in the implementation of the otherButtonPressed method.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[self dismissModalViewControllerAnimated:YES];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Run your project now and you should have a sample app which presents and dismisses your modal view. You can experiment with the parameters, try out different styles.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/6698523179679651554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/6698523179679651554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/6698523179679651554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/6698523179679651554'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/05/modal-views.html' title='Modal Views'/><author><name>Rounak</name><uri>http://www.blogger.com/profile/02439031547879761846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL2ZSDNjTftXW8tHcyeI_1Kq1dpKJE92F0WbMSgj8u8RZ9h3EnhuNJ3-tbwUzTtZjziniNavHQ8OqQGcNzNuu6Jncvk-sKPHy9ChRpSCCP7nvL-ALGdGDAHMf7GZYfTXfRtVHjv8_gBkEE/s72-c/P88845801.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-2896652824389409070</id><published>2011-05-08T16:04:00.000+05:30</published><updated>2011-05-08T16:04:27.857+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="concepts"/><category scheme="http://www.blogger.com/atom/ns#" term="delegate"/><category scheme="http://www.blogger.com/atom/ns#" term="delegation"/><category scheme="http://www.blogger.com/atom/ns#" term="ipod"/><category scheme="http://www.blogger.com/atom/ns#" term="uitableview"/><title type='text'>Delegation</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;On your way to developing apps you will encounter many situations when you would want to respond to certain events in your app but you would find it difficult to implement such actions in code.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;For example, you are downloading a file from the internet and you want to constantly update the progress on the screen for your user. Now to actually download stuff from the internet you would use built in classes like NSURLRequest which have been built by Apple. Now what Apple does in order for you to actually accomplish the task of showing progress is that, it tells the class NSURLRequest to send messages while it is downloading, to a class of your choice. So the NSURLRequest class is delegating tasks that it should be doing to a class of your choice. This class of your choice is known as delegate.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;I guess the concept should be very clear by now, some class sends messages to some other class so that the other class may complete tasks that the first class should have done.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Let us take another example where this is used, the TableView. The TableView is used in many iOS apps including Mail and iPod. The table view has cells, and each of those cells contain data. Many a times when you tap on a cell it does some action, for ex in the iPod app when you tap on a song it starts playing it. This is done by delegation.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPZMhxnz-VVaeFq9We0Li9N0FWPaGVIRBPGh94EhN19d6R5-iOblKf1HACUnhDEIz8hRRzDg0LQ3pqemAGQAqw0-G1SuMRdPn40_XA1HLdqH5KGkpotsK1RtxnBNxMDPtx9gLqCGyxQLIE/s1600/P85083000.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPZMhxnz-VVaeFq9We0Li9N0FWPaGVIRBPGh94EhN19d6R5-iOblKf1HACUnhDEIz8hRRzDg0LQ3pqemAGQAqw0-G1SuMRdPn40_XA1HLdqH5KGkpotsK1RtxnBNxMDPtx9gLqCGyxQLIE/s320/P85083000.jpg&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;So whenever a cell is tapped on a table view a message is sent to a class defined by you, let us call that class yourClass. Now what is meant by sending a message is that a predefined method specified and decided by Apple engineers is called in yourClass. In the case we are discussing, this method is tableView didSelectRowAtIndexPath is called when a cell is tapped.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;You have to implement this method in yourClass and in that you can include code to take whatever action you want in response to the cell-tapping. In case of the iPod app this method will start playing the selected song.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;For detailed instructions on how to include a tableView in your app refer to this &lt;a href=&quot;http://iosdevhelper.blogspot.com/2011/04/uitableview.html&quot;&gt;post&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;If you have still not got a clear idea about delegation I am very sure when you actually start delving deeper and deeper into iOS development your concepts will become clearer.&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/2896652824389409070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/2896652824389409070' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/2896652824389409070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/2896652824389409070'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/05/delegation_08.html' title='Delegation'/><author><name>Rounak</name><uri>http://www.blogger.com/profile/02439031547879761846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPZMhxnz-VVaeFq9We0Li9N0FWPaGVIRBPGh94EhN19d6R5-iOblKf1HACUnhDEIz8hRRzDg0LQ3pqemAGQAqw0-G1SuMRdPn40_XA1HLdqH5KGkpotsK1RtxnBNxMDPtx9gLqCGyxQLIE/s72-c/P85083000.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-3512054719399918233</id><published>2011-05-07T02:25:00.000+05:30</published><updated>2011-05-07T02:25:56.734+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="c"/><category scheme="http://www.blogger.com/atom/ns#" term="objective c"/><category scheme="http://www.blogger.com/atom/ns#" term="objective-c. syntax"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Objective-C Syntax</title><content type='html'>For a first timer coming from a language like C or PHP, objective C syntax does seem weird, but it takes only a few days to get familiar with it.&lt;br /&gt;
&lt;br /&gt;
The most striking difference in Objective C syntax is the way to call methods. In C or PHP when you call a method of a class through an object its something like this&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;returnvalue = objectname-&amp;gt;methodCallWithTwoParameters(n1,n2);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
However in Objective C the call is something like this&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;returnValue = [objectName methodCallWithParameterOne:n1 parameterTwo:n2];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;As you see the parameters are passed in the middle of the method name. The whole call is wrapped with square brackets.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/3512054719399918233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/3512054719399918233' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/3512054719399918233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/3512054719399918233'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/05/objective-c-syntax.html' title='Objective-C Syntax'/><author><name>Rounak</name><uri>http://www.blogger.com/profile/02439031547879761846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-3593062072414213004</id><published>2011-05-07T01:16:00.000+05:30</published><updated>2011-05-07T01:16:11.080+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="data"/><category scheme="http://www.blogger.com/atom/ns#" term="NSUserDefaults"/><category scheme="http://www.blogger.com/atom/ns#" term="plist"/><category scheme="http://www.blogger.com/atom/ns#" term="preferences"/><category scheme="http://www.blogger.com/atom/ns#" term="save"/><title type='text'>NSUserDefaults</title><content type='html'>This class helps you to easily save data (mostly preferences) to the iPhone so that you can recover it later.&lt;br /&gt;
So if you have an NSString, NSDictionary, NSArray,BOOL, NSDate or NSNumber you can easily use NSUserDefaults to store data.&lt;br /&gt;
&lt;br /&gt;
In the background the system stores all these data types in plists, so NSUserDefaults is also a&amp;nbsp;convenient method to deal with plists.&lt;br /&gt;
&lt;br /&gt;
To do this you would first want to get a reference to the object of this class. This is done by calling this method&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This is a shared object so even if you create two references to it, it will&amp;nbsp;&lt;/span&gt;ultimately&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;be the same.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now let us initialise a few variables so that we may store it for later use.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSString *name = [NSString stringWithString:@&quot;John&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSArray *subjects = [NSArray initWithObjects:@&quot;Physics&quot;,@&quot;Maths&quot;,@&quot;Management&quot;,nil];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSDate *joinDate = [NSDate date];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;We have three variables which we need to store into the system.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This is done by the following code&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[userDefaults setObject:name forKey:@&quot;Name&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[userDefaults setObject:subjects forKey:@&quot;Subjects&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[userDefaults setObject:joinDate forKey:@&quot;Date&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Each method call stores one object into memory.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;You can retrieve the saved data through the key so it is important to name it something which is relevant to the data being stored.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
Now that we have&amp;nbsp;successfully had a look at the code to store data let us move on to&amp;nbsp;retrieving&amp;nbsp;that data. For that you should have a reference to the NSUserDefaults object. The method objectForKey returns the stored data (in case of BOOL it is boolForKey: ) So let us retrieve the data we stored.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSString *savedName = [userDefaults objectForKey:@&quot;Name&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSArray *savedSubjects = [userDefaults objectForKey:@&quot;Subjects&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSDate *savedDate = [userDefaults objectForKey:@&quot;Date&quot;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
All of the above discussion was for objects, but there are a few data types like integers and floats which aren&#39;t objects but you might need to store them. The SDK has specific methods for each of them, here they are:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;setInteger:forKey:,integerForKey:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;setBool:forKey,boolForKey:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;setFloat:forKey,floatForKey:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;setDouble:forKey,DoubleForKey:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Even now one important question hasn&#39;t been answered yet, which is, when to save and retrieve this data?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
If this data is required at the start of the application itself this it would be a good idea to retrieve saved data in the applicationDidFinishLaunching method.&lt;br /&gt;
&lt;br /&gt;
You would want to save data when the home button is pressed, i.e your application is going to get closed or put into the background (iOS 4 and later). So the code for saving data should be put in a&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;pplicationWillTerminate: and&amp;nbsp;&lt;/span&gt;applicationWillResignActive:&lt;br /&gt;
&lt;br /&gt;
With this you should be able to effectively save state of your application and save user data.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/3593062072414213004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/3593062072414213004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/3593062072414213004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/3593062072414213004'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/05/nsuserdefaults.html' title='NSUserDefaults'/><author><name>Rounak</name><uri>http://www.blogger.com/profile/02439031547879761846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-7037096136717533816</id><published>2011-04-29T17:03:00.000+05:30</published><updated>2011-04-29T17:03:14.980+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="navigation bar"/><category scheme="http://www.blogger.com/atom/ns#" term="uinavigationcontroller"/><title type='text'>UINavigationController</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This design pattern presents a hierarchy of views, one leading into the other when something is tapped. The class used for implementing the is UINavigationController. The settings app is a well known example of an app that has its core functioning based on the navigation controller and table views.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.nimblekit.com/tutorials/navigation_interface.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;http://www.nimblekit.com/tutorials/navigation_interface.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
When you add the navigation controllers view to the window it will automatically add a navigation bar.&amp;nbsp;The first view of the view controller is known as the root view.&lt;br /&gt;
&lt;br /&gt;
Let us make a simple app which utilizes navigation controllers to present multiple views one after the other. Fire up XCode and click on a windows based app under projects. It sets up an app delegate and a nib file.&lt;br /&gt;
&lt;br /&gt;
Now in XCode create a new UIViewController sublass along with a nib from the new file menu. Name is rootViewController. It will generate a .h, .m and nib file.&lt;br /&gt;
&lt;br /&gt;
Again create a new UIViewController subclass and name it nextViewController. This also will generate three files.&lt;br /&gt;
&lt;br /&gt;
Now go to the .m file of the app delegate and import the first classes we declared. The statements would be like these&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;#import &quot;rootViewController.h&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inside the applicationDidFinishLaunching method in the implementation file of the app delegate&amp;nbsp;declare intances of both these classes&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;rootViewController *firstView = [[rootViewController alloc] init];&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Now we have to present this view as the first view in the navigation pattern. To do that we will create an instance of UINavigationController and add firstView as its rootViewController.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstView];&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Now we tell this app to add the navigation controller&#39;s view to the app window&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;[window addSubview:navController.view];&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Now that we no longer need a reference to firstView, we release it to properly handle memory&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;[firstView release];&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Go to the .h file of of the rootViewController, and add a method declaration buttonPressed &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;-(IBAction)buttonPressed:(id)sender&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;We have added the IBAction return type since we plan to hook this method to a button in Interface builder. This button will tell the navigation controller to present the next view in the hierarchy which is the nextViewController.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Go to the .m file of the rootViewController and implement the method we declared in the header file.&lt;br /&gt;
Also add the following line&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;#import &quot;nextViewController.h&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The method will bring in the next view. The code will be like&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New;&quot;&gt;-(IBAction)buttonPressed:(id)sender&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New;&quot;&gt;nextViewController *nextV = [[nextViewController alloc] init];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New;&quot;&gt;[self.navigationController pushViewController:nextV;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New;&quot;&gt;Now you set up a button in Interface builder, hook it up to this method and you&#39;re done.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/7037096136717533816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/7037096136717533816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/7037096136717533816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/7037096136717533816'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/uinavigationcontroller.html' title='UINavigationController'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-4728406142542332005</id><published>2011-04-24T23:17:00.001+05:30</published><updated>2011-04-24T23:20:01.955+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="interface"/><category scheme="http://www.blogger.com/atom/ns#" term="open source"/><category scheme="http://www.blogger.com/atom/ns#" term="ui"/><title type='text'>Mimicking popular iOS apps design patterns</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you are an app junkie like I am, many a times you would want to imitate a popular app&#39;s UI in your own app, for ex the pull to refresh introduced in twitter for iPhone (tweetie back then). But you may not be very comfortable with UIViews, which are essential for designing these types of interfaces, for this open source projects come to the rescue. The open source port of the pull to refresh feature was then adopted in a lot of other apps including facebook.&lt;br /&gt;
&lt;br /&gt;
A lot of other popular patterns like the iOS home screen, center button in tab bar (made popular in instagram), coverflow etc have open source ports, but the problem is that it is difficult to find the github (or where ever the source code is available) link for these projects.&lt;br /&gt;
&lt;br /&gt;
Enter&amp;nbsp;&lt;a href=&quot;http://cocoacontrols.com/&quot;&gt;http://cocoacontrols.com&lt;/a&gt;&amp;nbsp;, a repository of all such open source ports which has a rating system and a leaderboard as well. So the next time you want to mimic a UI pattern in your own app head to cocoa controls and look for it, in case you like it be sure to rate it as well for the benefit of others.&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/4728406142542332005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/4728406142542332005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/4728406142542332005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/4728406142542332005'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/mimicking-popular-ios-apps-design.html' title='Mimicking popular iOS apps design patterns'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-3202933726733081276</id><published>2011-04-24T15:04:00.000+05:30</published><updated>2011-04-24T15:04:14.036+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="alloc"/><category scheme="http://www.blogger.com/atom/ns#" term="memory"/><category scheme="http://www.blogger.com/atom/ns#" term="release"/><title type='text'>Memory Management</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;An important concept in programming is memory handling. If you come from C you might know of pointers, they point to a certain memory location. So if you declare&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;int *num&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;The num variable will point to a certain location in memory. To reserve this memory for future use in C malloc or calloc is used, and after this space is reserved it is totally our responsibility to handle it, the system won&#39;t use this space at all during the execution of the program. So let us reserve 10 bytes of memory by using malloc and letting num point to that block of memory. Now in case you have done all of this in a function, the memory is reserved though out runtime but the num pointer won&#39;t be accessible outside the function. So oustide the function even though the memory is reserved you won&#39;t be able to access that memory and make changes to it.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
Memory management in iOS is also very similar to this, almost all variables in iOS are pointers and memory is allocated to it through the alloc function. For ex if you want to allocate memory to an NSString pointer variable, you would do something like&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSString *string = [[NSString alloc] init];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;So now the string has been allocated memory and you may use it in your code. Now since you are the one who allocated memory to the string you should be the one to deallocate memory from it. Now the SDK offers a dealloc method which you can call explicitly to free up the allocated memory but this isn&#39;t considered good practice, instead the SDK provides a convenient way to tell the OS that you have done your bit towards memory handling and now it is totally the system&#39;s responsibility to take care of the memory and ensure that it doesn&#39;t leak. This practice comes in handy when the object is needed by the system but you don&#39;t need a reference to it anymore, for ex after adding a viewcontroller to the navigation controller, a reference to the view controller isn&#39;t generally required. So you would tell the OS that I am releasing the object from my side and now it is your responsibility to take care of it. This code fragment will better explain the view controller and navigation controller example&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UIViewController *vc = [[UIViewController alloc] init];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UINanigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[vc release];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;So in the first line we allocate memory to the view controller, in the second line we allocate memory to a navigation controller and assign the previously declared view controller as the navigation controllers root view controller. After doing this we no longer need a reference to vc so we call the release method on vc and tell the os to take care of the memory,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;So whenever you call alloc be sure to call release otherwise you will create a memory leak and increase the memory footprint of your app, you sure don&#39;t want that to happen.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/3202933726733081276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/3202933726733081276' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/3202933726733081276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/3202933726733081276'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/memory-management.html' title='Memory Management'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-8172147240154179078</id><published>2011-04-24T13:59:00.000+05:30</published><updated>2011-04-24T13:59:16.315+05:30</updated><title type='text'>Most common ios design patterns</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;When you have limited screen real estate design becomes very important. Putting in a lot of data without making the screen cluttered in very important when designing applications. This takes a lot of thinking and fortunately the engineers and ui experts at apple have done this thinking for you. They have provided easy to use design patterns in their sdk for making good, presentable and usable apps.&lt;br /&gt;
&lt;br /&gt;
Some of these deign patterns are&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Tab Bar&lt;/li&gt;
&lt;li&gt;navigation bar&lt;/li&gt;
&lt;li&gt;table views&lt;/li&gt;
&lt;li&gt;toolbars&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;Tab Bar&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://i166.photobucket.com/albums/u112/windsurfeta/iphone/show.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://i166.photobucket.com/albums/u112/windsurfeta/iphone/show.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;This design pattern presents a bar at the bottom of the screen with 3-5 icons on it which present different views.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Navigation bar&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.nimblekit.com/tutorials/navigation_interface.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;http://www.nimblekit.com/tutorials/navigation_interface.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;This patterns presents a hierarchy of views, which are related providing mechanisms to move back and forth in the heirarchy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Table View&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://three20.info/gfx/samples/iad1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://three20.info/gfx/samples/iad1.png&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;This view presents a scrollable list of items with each item very often presenting a view of its own. It is extremely effective in presenting a lot of data in limited screen size.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Tool bar&lt;/div&gt;&lt;div&gt;This was introduced in iOS 3.0 (it was called iPhone OS back then), its position is same as the tab bar, i.e at the bottom of the screen. You can see it in safari, mail and a lot of other applicaitons&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKl6QlvYjHVLXyY91SXZ3ZOkwowrW0hPoP_L9jKM3Rl7mjDYf9l4uwy2q6zFvOuY1KoYubHY3P_4TNyak2E9Ir-ZNOIt-Y4FErmCF6zraxLcYvK1ZMtD_35AjlNzvw9y9-Q8tKp7TNBRVj/s400/OfficeWebAppsExcelOnIPhone.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKl6QlvYjHVLXyY91SXZ3ZOkwowrW0hPoP_L9jKM3Rl7mjDYf9l4uwy2q6zFvOuY1KoYubHY3P_4TNyak2E9Ir-ZNOIt-Y4FErmCF6zraxLcYvK1ZMtD_35AjlNzvw9y9-Q8tKp7TNBRVj/s320/OfficeWebAppsExcelOnIPhone.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Personal opinion, I believe putting a toolbar on top of a tab bar is a horrible idea.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;For further reading you can refer to apple&#39;s&amp;nbsp;&lt;a href=&quot;http://developer.apple.com/library/ios/DOCUMENTATION/UserExperience/Conceptual/MobileHIG/Introduction/Introduction.html&quot;&gt;iOS Human Interface Guidelines&lt;/a&gt;&amp;nbsp;,&lt;/div&gt;&lt;div&gt;also pttrns is a great site which assembles the best UIs in the AppStore for your reference&amp;nbsp;http://pttrns.com/&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/8172147240154179078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/8172147240154179078' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/8172147240154179078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/8172147240154179078'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/most-common-ios-design-patterns.html' title='Most common ios design patterns'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://i166.photobucket.com/albums/u112/windsurfeta/iphone/th_show.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-5097432555959743876</id><published>2011-04-24T13:02:00.000+05:30</published><updated>2011-05-07T02:30:48.296+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="plist"/><title type='text'>plists</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you have ever gone through the ios filesystem you will find lots and lots of plists. Plists or property lists are basically xml files used to store information on the iphone.&lt;br /&gt;
&lt;br /&gt;
A plist can store arrays, strings, nsdata, numbers, dates and nsdictionaries.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://macdevcenter.com/mac/2005/05/03/graphics/plist.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://macdevcenter.com/mac/2005/05/03/graphics/plist.jpg&quot; width=&quot;301&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
A plist has a basic structure, with one root element and everything under it.&lt;br /&gt;
&lt;br /&gt;
Let us make a plist to save contacts (this may be a bad practice and is only for illustration purposes)&lt;br /&gt;
So to start with let the root element of our plist be an array which will hold all the contacts.&lt;br /&gt;
Each element of the array will be an nsdictionary with key value pairs as follows&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;id - nsnumber&lt;/li&gt;
&lt;li&gt;name - nsstring&lt;/li&gt;
&lt;li&gt;phone - nsstring&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;It is a very simple structure and the iOS sdk offers a lot of&amp;nbsp;convenience&amp;nbsp;methods to load data from plists into arrays or dictionaries.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;So during the first run of our program we would want to create a plist and save it to some locations, this location will most likely be your documents&amp;nbsp;directory&amp;nbsp;since it is automatically backed up by iTunes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;So first we need to get the path for the documents directory of our app, we get this through the following code&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSString *writeReadPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@&quot;contacts.plist&quot;];&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;As you see the second line has the filename of the plist appended to the path of the documents directory we got, in this case we have named the file to be contacts.plist .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now that we have got the path to our file, let us proceed to writing data on our file. If it is the first run of the app there is a possibility the file doesn&#39;t exist, to tackle this issue we add a few lines of code and create the plist with sample data&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSFileManager *fileManager = [NSFileManager defaultManager];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;if (![fileManager fileExistsAtPath:writeReadPath]) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; NSDictionary *contact1 = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:[NSNumber numberWithInt:1],@&quot;John&quot;,@&quot;1944232321&quot;,nil] forKeys:[NSArray arrayWithObjects:@&quot;id&quot;,@&quot;name&quot;,@&quot;phone&quot;,nil]];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;NSDictionary *contact2 = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:[NSNumber numberWithInt:2],@&quot;Steve&quot;,@&quot;1944232421&quot;,nil] forKeys:[NSArray arrayWithObjects:@&quot;id&quot;,@&quot;name&quot;,@&quot;phone&quot;,nil]];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;NSDictionary *contact3 = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:[NSNumber numberWithInt:3],@&quot;Peter&quot;,@&quot;1944132321&quot;,nil] forKeys:[NSArray arrayWithObjects:@&quot;id&quot;,@&quot;name&quot;,@&quot;phone&quot;,nil]];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; NSArray *contacts = [NSArray arrayWithObjects:contact1,contact2,contact3,nil];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[contacts writeToFile:writeReadPath atomically:YES];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;With this much of code we have managed to create a new plist file, add contacts to it, without even going to deep into file handling. Thanks to the&amp;nbsp;convenience methods of nsarray and nsdictionary it becomes very easy to write data into plists.&amp;nbsp;In future posts we will deal with editing and deleting items from a plist.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/5097432555959743876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/5097432555959743876' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/5097432555959743876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/5097432555959743876'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/plists.html' title='plists'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-4292889155608734072</id><published>2011-04-24T12:22:00.000+05:30</published><updated>2011-04-24T13:19:56.446+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="uitabbar"/><category scheme="http://www.blogger.com/atom/ns#" term="uitabbarcontroller"/><title type='text'>UITabBarController</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is another common design pattern found in iOS apps, it includes a bar (generally black) at the bottom of the screen with various icons which when tapped load up different views.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6fiVGZ45-UK9-21Exv8yplKhtOly0Vfw2WsdhEUL44YC4gQV0kGERDx3YMbUashyphenhyphenlSYDxtbbkUmus3uW1ne2Oa2SCmfPpJzeTLl8qVfqavCjgHN-OT4xuO8uVKIRO9Pc_tO_ixBO7am9H/s1600/Screen+shot+2010-07-25+at+12.53.26+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6fiVGZ45-UK9-21Exv8yplKhtOly0Vfw2WsdhEUL44YC4gQV0kGERDx3YMbUashyphenhyphenlSYDxtbbkUmus3uW1ne2Oa2SCmfPpJzeTLl8qVfqavCjgHN-OT4xuO8uVKIRO9Pc_tO_ixBO7am9H/s320/Screen+shot+2010-07-25+at+12.53.26+PM.png&quot; width=&quot;211&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;tabbar&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;Each icon (button) is actually a separate viewController with the title of the viewController displayed below each of the icon.&lt;br /&gt;&lt;br /&gt;The uitabbarcontroller has a viewControllers property to which an array of viewControllers is assigned. Generally tabbarcontrollers have four or five viewControllers. In case there are more than 5 view controllers a more icon is created like the one seen above which has the rest of the viewcontrollers.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/4292889155608734072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/4292889155608734072' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/4292889155608734072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/4292889155608734072'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/uitabbarcontroller.html' title='UITabBarController'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6fiVGZ45-UK9-21Exv8yplKhtOly0Vfw2WsdhEUL44YC4gQV0kGERDx3YMbUashyphenhyphenlSYDxtbbkUmus3uW1ne2Oa2SCmfPpJzeTLl8qVfqavCjgHN-OT4xuO8uVKIRO9Pc_tO_ixBO7am9H/s72-c/Screen+shot+2010-07-25+at+12.53.26+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7795555183656225888.post-1750968732700103024</id><published>2011-04-23T20:32:00.000+05:30</published><updated>2011-05-08T14:54:50.075+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="uitableview"/><category scheme="http://www.blogger.com/atom/ns#" term="viewcontroller"/><title type='text'>UITableView</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The UITableView is a very common design pattern used in iOS apps. They help in presenting a lot of data in limited screen real estate.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://adeem.me/blog/wp-content/uploads/2009/UITableView/SimpleUITableView/Picture%2011.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://adeem.me/blog/wp-content/uploads/2009/UITableView/SimpleUITableView/Picture%2011.png&quot; width=&quot;177&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Setting up a UITableView requires a delegate and a data source to be implemented. In case you&#39;re not familiar with the delegation and data source concepts, think of it like this, the delegate is a class which tells the OS, how to present the table view, for ex its size, the modes in which the table view should be like editing, normal etc. The data source, as the name suggests provides data to the table view to present it on the screen.&lt;br /&gt;
&lt;br /&gt;
This was about the concept of delegation and data source, to actually implement it, you should declare one of your classes (view controller, preferably with a nib file as well) as the UITableViewDelegate and the UITableViewDataSource. This is done by adding &amp;lt;UITableViewDelegate&amp;gt;, &amp;lt;UITableViewDataSource&amp;gt; after the class declaration in the header (.h) file, like this :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;@interface MainViewMulti : UIViewController &amp;lt;UITableViewDelegate,UITableViewDataSource&amp;gt; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;//class members&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To actually add the table view you can either do it through code or interface builder. Interface builder is preferred if you have relatively simple tasks. So click on the nib file linked with your view controller, it will open interface builder. Now in the library search for tableview and drag it to your nib.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYkMJ8cfXhJCJ6LfwsdjI4reROpLJlVsgjYma7XL10TTPkZUxehRpQMEbl2AXGh3lp1xKJK1AHjtDbixmAhVWnRRZvK_cGSHebCrEAAqwKmdFBrXhazgixqyGOUurqm6oVs65qTl7M0qdE/s1600/ib+tableview.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYkMJ8cfXhJCJ6LfwsdjI4reROpLJlVsgjYma7XL10TTPkZUxehRpQMEbl2AXGh3lp1xKJK1AHjtDbixmAhVWnRRZvK_cGSHebCrEAAqwKmdFBrXhazgixqyGOUurqm6oVs65qTl7M0qdE/s320/ib+tableview.png&quot; width=&quot;150&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
After doing that right click on the table view you just dragged, there will be delegate and datasource outlets, drag it to the files owner. This tells the table view that the class you&#39;ve declared is its delegate and data source.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj64sN0gIznR1pzHMlusDYa33Tuo5rJuqZ6j01B7bp3rKiFZzO6iil-juUyBTFpcvp8b-r30ICjQ-v1PJt7-LYAAey8RkvNogwog2kyFbHkczde15OP7-a49pCn-S77bzOBx_hZgSMQHx6C/s1600/drag.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj64sN0gIznR1pzHMlusDYa33Tuo5rJuqZ6j01B7bp3rKiFZzO6iil-juUyBTFpcvp8b-r30ICjQ-v1PJt7-LYAAey8RkvNogwog2kyFbHkczde15OP7-a49pCn-S77bzOBx_hZgSMQHx6C/s320/drag.png&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Now that you have declared your class as the delegate and the data source it is time to implement mandatory methods which will provide data and set up the the tableviewcells.&lt;br /&gt;
&lt;br /&gt;
The apple documentation says that the following methods are mandatory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The first method tells the device, how many rows do you want, that value is specified by the return value of that method.&lt;br /&gt;
&lt;br /&gt;
The second method tells the device what contents to put in each row of the table view. This method is called for each row.&lt;br /&gt;
&lt;br /&gt;
Right now you have the basic framework required for setting up a table view. You can use this as a template for all of you tableviews.&lt;br /&gt;
&lt;br /&gt;
Now to actually put data in your table view let us declare an array in the header file, and populate it with nsstrings. Let us name the array tableDataSource, to populate it insert the following code in your viewDidLoad method&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #4e4e4e; line-height: 14px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;tableDataSource = [[NSArray alloc] initWithObjects:@&quot;Monday&quot;, @&quot;Tuesday&quot;, @&quot;Wednesday&quot;, @&quot;Thursday&quot;, @&quot;Friday&quot;, @&quot;Saturday&quot;, @&quot;Sunday&quot;,nil];&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In case you aren&#39;t familiar with arrays, this is one of the&amp;nbsp;convenience methods to directly assign an array with objects.&lt;br /&gt;
&lt;br /&gt;
Now the table view will contain as many rows as the number of objects in the array, so to tell this to the os add the following line to your&amp;nbsp;- &amp;nbsp;numberOfRowsInSection method&lt;br /&gt;
return tableDataSource.count&lt;br /&gt;
&lt;br /&gt;
The only thing left now is to populate each row of the tableview with the items in the array, to do this add the following code to your cellForRowAtIndexPath method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;static NSString *SimpleTableIdentifier = @&quot;SimpleTableIdentifier&quot;;
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier] autorelease];
}

NSUInteger row = [indexPath row];
cell.textLabel.text = [tableDataSource objectAtIndex:row];
return cell;
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Now save everything (including the nib files) build your project and you should see the table view with the items you set in the simulator.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Next we will discuss how to put the table view in edit mode and how to add and delete items from the tableview.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iosdevhelper.blogspot.com/feeds/1750968732700103024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7795555183656225888/1750968732700103024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/1750968732700103024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7795555183656225888/posts/default/1750968732700103024'/><link rel='alternate' type='text/html' href='http://iosdevhelper.blogspot.com/2011/04/uitableview.html' title='UITableView'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYkMJ8cfXhJCJ6LfwsdjI4reROpLJlVsgjYma7XL10TTPkZUxehRpQMEbl2AXGh3lp1xKJK1AHjtDbixmAhVWnRRZvK_cGSHebCrEAAqwKmdFBrXhazgixqyGOUurqm6oVs65qTl7M0qdE/s72-c/ib+tableview.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>