<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Scale</title>
	<atom:link href="http://blog.webscale.co.in/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.webscale.co.in</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 08 May 2010 18:34:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flow Aware Hibernate Stats</title>
		<link>http://blog.webscale.co.in/?p=366</link>
		<comments>http://blog.webscale.co.in/?p=366#comments</comments>
		<pubDate>Thu, 08 Oct 2009 10:19:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[hibernate]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=366</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>In production you may have run into problems where a certain flow is slow, turning hibernate statistics on using the jmx-console would be a good idea, but debugging what actually corresponds to this slow flow could be like searching for a needle in this haystack. The obvious thing would be to organize the data in such a way that all queries for a flow along with their time are presented together. The blog discusses one approach for doing so assuming we are using spring and hibernate.</p>
<p>In our case we were interested in the hql, sql and time taken for them. We were also running into some issues with the session size, so had a piece to capture that too. The whole approach is based on these simple steps:</p>
<ol>
<li>Putting in a flow identifier</li>
<li>Inject our own SessionStatsCollector</li>
<li>Wire it via JMX</li>
<li>Get callbacks for the original sql</li>
</ol>
<p><strong>Flow identifier</strong><br />
The utility of this approach depends on how easily can we pin point each flow. The url along with the thread id is a good starting point. However if the urls are kind of the same and the request parameters have a special token, we can use that as our flow discriminators. This token is injected into the NDC for the later part of the tool to pick it up and arrange diagnostic information.</p>
<p><strong>Inject SessionStatsCollector</strong><br />
Hibernate does not allow any hook points to the session stats collector, so to get our custom stats collector in, we used a simple cglib proxy for it. The proxy intercepts only queryExecuted and closeSession methods. While queryExecuted is used to capture the hql, time and number of rows, closeSession callbacks helps us log all the collected information together.</p>
<p><strong>Wire it via JMX</strong><br />
Since the original mbean does not support logging flows, the new jmx bean exposes one method profileFlows which takes the flow pattern and a boolean to indicate if the session size should be logged. Determining the session size is a heavy operation, so on most cases we may not want to do so. There is another method to reset the bean which would revert to the original statistics collector from our souped up version.</p>
<p><strong>Sql callbacks</strong><br />
We were interacting with our dba group, for whom the hql was like greek, so the original sql was important to us, since the original stats implementer does not get any callbacks for this, we injected our own entity interceptor which gives a callback to the stats collector for the sql.</p>
<p>So in short with about 8 classes, we can create something which gives us some indicators of the flow performances. The performance and memory overhead introduced by this is nominal and can be turned off at any point.</p>
<p>The classes for this are easy to code, if laziness gets in your way, post a comment and will upload it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=366</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integrating Web Applications with GWT/GXT &#8211; The Pitfalls (Contd.)</title>
		<link>http://blog.webscale.co.in/?p=315</link>
		<comments>http://blog.webscale.co.in/?p=315#comments</comments>
		<pubDate>Mon, 24 Aug 2009 14:25:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[GXT]]></category>
		<category><![CDATA[pitfall]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=315</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p><strong>GWT RPC White List Magic</strong><br />
The reason I used the word magic is because that’s how it came across to me when I first came against this problem.  <strong>This issue is more peculiar when one is using GXT and passing data back and forth between client and server using classes extending <code>BaseModelData</code>.<span id="more-315"></span></strong></p>
<p>The general convention of writing your model classes is as following:</p>
<pre style="height: 250px;">public class NameObj extends BaseModelData {

     public String getFirstName() {
          return this.get(“firstname”);
     }

     public void setFirstName (String name) {
          this.set(“firstname”, name);
     }

}

public class Person extends BaseModelData {

     public NameObj getName() {
          return this.get(“name”);
     }

     public void setName(NameObj name) {
          this.set(“name”, name);
     }
     //so on
}

<strong>RPC Interface method</strong>

     public Person getPersonList(args);</pre>
<p>The above code points to one key convention especially when using GXT. We declare getter and setter for concrete types we want to deal with, <strong>but we need not want to declare data members for them as everything is being sent in the <code>BaseModelData</code> map.</strong></p>
<p><strong>Now the pitfall!! </strong>Since the <code>NameObj</code> was not declared as a data member of the <code>Person</code> class and only <code>Person</code> class is defined to be part of the RPC interface, <strong>GWT compiler would not add the <code>NameObj</code> class to RPC whitelist i.e. while serializing RPC response, </strong>GWT will most probably complain with the following error.</p>
<pre>Caused by: com.google.gwt.user.client.rpc.SerializationException: Type
'com.myclassNameObj was not included in the set of types which can be
serialized by this SerializationPolicy or its Class object could not
be loaded.</pre>
<p>A similar issue is reported on the following link as well.<br />
<a href="http://osdir.com/ml/GoogleWebToolkit/2009-04/msg01287.html">http://osdir.com/ml/GoogleWebToolkit/2009-04/msg01287.html</a></p>
<p>Thus the GWT compiler smartly works on to find which are the essential classes which need to be serialized as it has the direct implication <strong>on amount of javascript compiler would generate and would be required to be downloaded on the browser. </strong>Since we were using GXT, we needed to set data in <code>BaseModelData</code> as GXT classes would work when data comes in the base model data map.</p>
<p>The current workaround which we came up with is a way to fake with GWT <strong>by declaring unused variables for the classes as following:</strong></p>
<pre>public class Person extends BaseModelData {

     @SuppressWarnings(“unused”)
     private NameObj _nameObj

     public NameObj getName() {
          return this.get(“name”);
     }

     public void setName(NameObj name) {
          this.set(“name”, name);
     }
     //so on
}</pre>
<p>This may not be <strong>the best way to deal with this issue, but as of now, I could not find any other approach.</strong> Anyone is welcome to suggest a better alternative.</p>
<p><strong>I would publish another article soon on using dynamic Intenationalization with GWT</strong> by using a smarter way than writing a huge array. But that discussion merits a separate article.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=315</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Is Implementing Equals and HashCode Enough ?</title>
		<link>http://blog.webscale.co.in/?p=343</link>
		<comments>http://blog.webscale.co.in/?p=343#comments</comments>
		<pubDate>Mon, 24 Aug 2009 11:34:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basic]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=343</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>As per <em>Joshua Bloch</em> <strong>Effective Java Second Edition</strong>, <em><strong>I</strong><strong>tem 9 Always override hashCode when you override equals.</strong></em></p>
<p><em>&#8220;You must override hashCode in every class that overrides equals. Failure to do so<br />
will result in a violation of the general contract for Object.hashCode, which will<br />
prevent your class from functioning properly in conjunction with all hash-based<br />
collections, including HashMap, HashSet, and Hashtable.&#8221;</em></p>
<p>Another Important Line from the Effective Java <em>&#8220;In hashCode method you must exclude any fields that are not used in equals comparisons,<br />
or you risk violating the second provision of the hashCode contract&#8221;(To refer to contract look into Object.java (<a title="Object#hashCode" href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode()">javadoc</a>))</em></p>
<p>I want to add to this and say <em><strong>:</strong></em></p>
<p><em><strong>Always compareTo method should reflect same logic as you have in equals. <span id="more-343"></span><br />
</strong></em></p>
<p><strong>Why so ?</strong></p>
<p>If you will override hashCode then true your hash-based collections will work but what about collections which are not hash-based (you will ask are there any.).Yes collections like TreeSet(This class implements the <tt>Set</tt> interface, backed by a <tt>TreeMap</tt> instance),TreeMap(Red-Black tree based implementation of the <tt>SortedMap</tt> interface) are not hash-based.</p>
<p><strong>How do they Work then ?</strong></p>
<p>These collections depend on compareTo method which is available in Comparable Interface or compare Method which is available in Comparator Interface. So either these collections can be given Comparator instance or the objects being added in these collections implement Comparable Interface.</p>
<p><strong>Why do the need compareTo or compare ?</strong></p>
<p>Remember First Lecture on Binary Trees.There is a root node and it has child which can be either left of it or right of it. Now how is it decided in TreeMap, well you might have guessed it by now.These compareTo and compare methods are used for it.In Order to decide whether new element has to be added (seacrhed for) in left of or right of the root node depends on the outcome of  compareTo, if outcome is negative integer then in left otherwise in right.(Or if they are equal then change the value of that node, as set doesnt allow duplicates)</p>
<p><strong>What will happen if i screw up this method ?</strong></p>
<p>Lots of bad things will happen:</p>
<p><em> You will never find your Object which you put in the Collection ?</em></p>
<p>Well its dangerous can you explain it in more detail. Here is the case you have a equals method which is not in sync with compareTo method then contains() method invoked with the equal object will return false. So one contract is the if two objects are equal then compareTo must return &#8220;Zero&#8221;.</p>
<p>From the Javadoc of compareTo</p>
<p>&#8220;It is generally the case, but <em>not</em> strictly required that <tt>(compare(x,  y)==0) == (x.equals(y))</tt>. Generally speaking, any comparator that violates  this condition should clearly indicate this fact. The recommended language is  &#8220;Note: this comparator imposes orderings that are inconsistent with equals.&#8221;</p>
<p>I dont know why they didnt make it required. It should have been a required condition as otherwise contains() operation will be screwed on collection. You are not always going to do contains check with the same object which is already in Collection.You might have the Equal object (The Object  for which equals() return true.) and you want to check if this exist in collection and want to find the object which exists.Typical use case can be in Hibernate you have a transient object and you want to find persistent instance from the collection and then sync the properties from transient to persistent object.</p>
<p><strong>How should we implement compareTo then ?</strong></p>
<p>Well you need to satisfy this condition <tt>(compare(x,  y)==0) == (x.equals(y)) </tt>at any cost. One way is you can use <a title="CompareToBuilder" href="http://commons.apache.org/lang/api/org/apache/commons/lang/builder/CompareToBuilder.html">CompareToBuilder </a>and append all the fields which are in equals.</p>
<p><strong>Out of Curiosity if equals condition you mentioned is satisfied but for all others results are biased i mean i am always growing tree in one direction say always compareTo returns greater Then Zero for every object. Will it screw up Performance ?</strong></p>
<p>Nice , so you have finally data structures running in mind. Well it has been affected had it been just a Binary Tree.But its smarter than that, its a Red-Black Tree.</p>
<p>&#8220;The constraints of Red Black tree enforce a critical property of red-black trees: that the longest path from the root to any leaf is no more than twice as long as the shortest path from the root to any other leaf in that tree. The result is that the tree is roughly balanced. Since operations such as inserting, deleting, and finding values require worst-case time proportional to the height of the tree, this theoretical upper bound on the height allows red-black trees to be efficient in the worst-case, unlike ordinary <a title="Binary search tree" href="http://en.wikipedia.org/wiki/Binary_search_tree">binary search trees</a>.&#8221;</p>
<p><!-- /* Font definitions */ html         { font-family: 'Tahoma',sans-serif; font-size: 8pt; font-style: normal; font-weight: normal; } body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size:1em; } pre				{ font-family: monospace; }  /* Margins */ body	     { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; } h1           { margin-top: 0.3em; margin-bottom: 0.04em; }	 h2           { margin-top: 2em; margin-bottom: 0.25em; } h3           { margin-top: 1.7em; margin-bottom: 0.25em; } h4           { margin-top: 2em; margin-bottom: 0.3em; } h5           { margin-top: 0px; margin-bottom: 0px; } p            { margin-top: 1em; margin-bottom: 1em; } pre	         { margin-left: 0.6em; } ul	         { margin-top: 0px; margin-bottom: 1em; } li	         { margin-top: 0px; margin-bottom: 0px; }  li p	     { margin-top: 0px; margin-bottom: 0px; }  ol	         { margin-top: 0px; margin-bottom: 1em; } dl	         { margin-top: 0px; margin-bottom: 1em; } dt	         { margin-top: 0px; margin-bottom: 0px; font-weight: bold; } dd	         { margin-top: 0px; margin-bottom: 0px; }  /* Styles and colors */ a:link	     { color: #0000FF; } a:hover	     { color: #000080; } a:visited    { text-decoration: underline; } h4           { font-style: italic; } strong	     { font-weight: bold; } em	         { font-style: italic; } var	         { font-style: italic; } th	         { font-weight: bold; } -->As per javadoc of <a title="TreeMap" href="http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html">TreeMap</a></p>
<p>&#8220;This implementation provides guaranteed log(n) time cost for the  <tt>containsKey</tt>, <tt>get</tt>, <tt>put</tt> and <tt>remove</tt> operations.  Algorithms are adaptations of those in Cormen, Leiserson, and Rivest&#8217;s  <em>Introduction to Algorithms</em>.&#8221;</p>
<p><strong>Still didnt understand ? But How remeber you said that it will keep adding in one direction ?</strong></p>
<p>Well enough of spoon feeding. Open TreeMap. java and look into put method. You will find some method like fixAfterInsertion().It will keep balancing the tree after every insert.So it will be invoked after every Insert.</p>
<p><strong>Dude You are driving me crazy.Do you think I am dumb.Isn&#8217;t fixAfterInsertion method take time ?</strong></p>
<p>Well that&#8217;s beauty of Red-Black Tree.fixAfterInsertion takes O(log(n)), but as it happens after insertion so total time will be O(log(n)) +O(log(n)) which is O(2log(n)) which is anyway O(log(n)).The rotateRight and rotateLeft are constant time operations.You understand constant means O(1).</p>
<p><em><strong>Never mind coming back to original topic ,another important para which mandates requirment of compareTo and equals to be consistent.</strong></em></p>
<p>&#8220;Note that the ordering maintained by a sorted map (whether or not an explicit  comparator is provided) must be <em>consistent with equals</em> if this sorted map  is to correctly implement the <tt>Map</tt> interface. (See <tt>Comparable</tt> or <tt>Comparator</tt> for a precise definition of <em>consistent with  equals</em>.) This is so because the <tt>Map</tt> interface is defined in terms  of the equals operation, but a map performs all key comparisons using its  <tt>compareTo</tt> (or <tt>compare</tt>) method, so two keys that are deemed  equal by this method are, from the standpoint of the sorted map, equal. The  behavior of a sorted map <em>is</em> well-defined even if its ordering is  inconsistent with equals; it just fails to obey the general contract of the  <tt>Map</tt> interface.&#8221;</p>
<p><strong>I want to see from my own Eyes ?</strong></p>
<p>Download the Test Project from <a title="Test Tree Collections" href="http://blog.webscale.co.in/wp-content/uploads/2010/05/TestTreeCollections.zip">here.</a></p>
<p>Thanks. Hope you enjoyed reading and learnt some thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=343</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Integrating Web Applications with GWT/GXT &#8211; The Pitfalls</title>
		<link>http://blog.webscale.co.in/?p=314</link>
		<comments>http://blog.webscale.co.in/?p=314#comments</comments>
		<pubDate>Wed, 19 Aug 2009 18:09:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[GXT]]></category>
		<category><![CDATA[pitfalls]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=314</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>This main focus is to point out some of the pitfalls which one may land into while <strong>writing the server side code </strong>for a GWT using especially when you are a beginner. Since <strong>Google&#8217;s <a href="http://code.google.com/webtoolkit/overview.html">GWT tutorial</a></strong> <strong>is really good and very extensive, </strong>this article is not explaining how to write code in GWT but some of the points which one needs to handle on the server side when GWT is the UI interface of the application. I am not an expert in GWT application, but just sharing my experience of integrating GWT in a web application for the first time. So you can definitely improve or suggest alternatives listed below.</p>
<p><span id="more-314"></span>The reason I have mentioned GXT also in the title is because of the similarity in issue we would face as both use GWT compiler in the background. Further I came across these problems when we started integrating GXT with our existing web application.</p>
<p><strong>Handling authentication</strong></p>
<p><strong> </strong>A typical requirement of any web application is to check every request is coming from an authentic source. This involves checking either a session attribute kind of thing which is set once the user has logged in or using request headers or data to validate the user credentials. <strong>Since any decent sized application would have multiple RPC interfaces exposed </strong>(especially if different pages of an application are GWT enabled instead of the entire application), we <strong>need a kind of base servlet which is extended by all RPC servlet </strong>implementations in the application.</p>
<p><img class="aligncenter size-full wp-image-334" title="GWT RemoteService Model" src="http://blog.webscale.co.in/wp-content/uploads/2009/08/post-314_1.png" alt="GWT RPC Model" width="590" height="354" /></p>
<p>Once you architect your servlets into this design, <strong>the next important aspect is to hook in </strong>the authentication logic so that GWT sends the callback to appropriate method in the base servlet before executing any method in the interface implementations. Fortunately GWT already gives you such methods. The method <code><strong>onBeforeRequestDeserialized</strong></code> in <code>RemoteServiceServlet</code> can be overridden in the base servlet, to provide the basic authentication code of the application.</p>
<p>Similarly to add any custom post processing after a RPC method is executed, one can override, <strong><code>onAfterResponseSerialized</code></strong> method.</p>
<p>Consider the <strong>scenario when authentication fails or the user session has timed out. </strong>Typically one likes to throw some exception like <code>AuthenticatonException</code>. <strong>But the RPC interface method ideally should not declare such exceptions in the throws clause of the methods as it’s not really part of the method contract.</strong></p>
<p>This is the <strong>first pitfall we would land up in the GWT world! </strong>Since the authentication exception is not declared to be thrown from the interface, <strong>GWT RPC framework would not add it to its Serialization Policy. </strong></p>
<p>The workaround which we figured out was to inject our own serialization policy for the given exception.</p>
<p>Following are the implementation steps</p>
<ol>
<li><strong>Create a Map </strong>with Class object as key and Boolean as value (indicating      following class is to be serialized)</li>
<li><strong>Add the <code>Authetication      Exception</code> </strong>to the <code>Map</code>. Remember, <strong>all its parent classes have to be      added explicitly to the serialization policy map. </strong>E.g. If      <code>AuthenticationException extends RuntimeException</code> then add      <code>RuntimeException</code>, Exception and Throwable classes to the serialization      policy map.</li>
<li><strong>Declare the      <code>StandardSerializationPolicy</code> object with the above map </strong>as the constructor argument.
<p>//code snippet</p>
<pre>Map&lt;Class&lt;?&gt;, Boolean&gt; exceptionMap = new HashMap&lt;Class&lt;?&gt;, Boolean();

exceptionMap.put(AuthenticationException.class, true);

exceptionMap.put(RuntimeException.class, false);

exceptionMap.put(Exception.class, false);

exceptionMap.put(Throwable.class, false);</pre>
</li>
<li><strong>Override <code>doUnexpectedFailure</code> method of <code>RemoteServiceServlet</code> and if exception received in <code>AuthenticationException</code></strong>, prepare the response string using <code>encodeResponseForFailure</code> method from RPC until class passing the custom serialization policy. (Internally GWT code uses the same code with standard generated serialization policy).
<pre>String responseStr = RPC.encodeResponseForFailure(null, e, preprocessingExceptionPolicy);

RPCServletUtils.writeResponse(getServletContext(), getThreadLocalResponse(), responseStr, false);</pre>
</li>
</ol>
<p>That’s it. This would allow you to throw exception which are not declared by RPC interface from the callback methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=314</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhone Tutorial: Creating a custom Table View Cell</title>
		<link>http://blog.webscale.co.in/?p=284</link>
		<comments>http://blog.webscale.co.in/?p=284#comments</comments>
		<pubDate>Tue, 28 Apr 2009 14:26:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=284</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>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 your 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:</p>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SfcJL4OhSYI/AAAAAAAAATE/4debKHb4Aqw/s1600-h/screen-capture.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"> <img id="BLOGGER_PHOTO_ID_5329738783692769666" style="cursor: pointer; width: 211px; height: 400px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SfcJL4OhSYI/AAAAAAAAATE/4debKHb4Aqw/s400/screen-capture.jpg" border="0" alt="" /></a></div>
<div>For basics and list of topics you can refer this post:</div>
<div><a href="http://blog.webscale.co.in/?p=143" target="_blank">iPhone Tutorial: Everything you need for a Business Application</a></div>
<p><span id="more-284"></span>
<div>So to start open xcode and create a new project, chose the template as &#8220;Navigation Based&#8221; and  name it as &#8220;CustomCellTestProject&#8221;. What template you chose does not matter, refer my previous posts to find how you can start working on any template.</div>
<div>First thing we will do is create a customCell. Right click on Classes and add a new UITableViewCell subclass. Name it as &#8220;CustomCell&#8221;. Now open CustomCell.h and add the following code:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#643820;">#import </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">@interface</span> CustomCell : UITableViewCell {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#5c2699;">UILabel</span><span style="color:#000000;"> *</span>primaryLabel<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#5c2699;">UILabel</span><span style="color:#000000;"> *</span>secondaryLabel<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">UIImageView</span> *myImageView;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;">@property<span style="color:#000000;">(</span>nonatomic<span style="color:#000000;">,</span>retain<span style="color:#000000;">)</span><span style="color:#5c2699;">UILabel</span><span style="color:#000000;"> *</span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;">@property<span style="color:#000000;">(</span>nonatomic<span style="color:#000000;">,</span>retain<span style="color:#000000;">)</span><span style="color:#5c2699;">UILabel</span><span style="color:#000000;"> *</span><span style="color:#3f6e74;">secondaryLabel</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;">@property<span style="color:#000000;">(</span>nonatomic<span style="color:#000000;">,</span>retain<span style="color:#000000;">)</span><span style="color:#5c2699;">UIImageView</span><span style="color:#000000;"> *myImageView;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;">@end</p>
<div><span style="color: #aa0d91;  font-family:Monaco;font-size:10px;"><br />
</span></div>
<div>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</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">id</span>)initWithFrame:(<span style="color:#5c2699;">CGRect</span>)frame reuseIdentifier:(<span style="color:#5c2699;">NSString</span> *)reuseIdentifier {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">if</span> (<span style="color:#aa0d91;">self</span> = [<span style="color:#aa0d91;">super</span> <span style="color:#2e0d6e;">initWithFrame</span>:frame <span style="color:#2e0d6e;">reuseIdentifier</span>:reuseIdentifier]) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"> </span>// Initialization code</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>primaryLabel<span style="color:#000000;"> = [[</span><span style="color:#5c2699;">UILabel</span><span style="color:#000000;"> </span><span style="color:#2e0d6e;">alloc</span><span style="color:#000000;">]</span><span style="color:#2e0d6e;">init</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">primaryLabel</span>.textAlignment = <span style="color:#2e0d6e;">UITextAlignmentLeft</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">.font = [</span><span style="color:#5c2699;">UIFont</span><span style="color:#000000;"> </span>systemFontOfSize<span style="color:#000000;">:</span><span style="color:#1c00cf;">14</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>secondaryLabel<span style="color:#000000;"> = [[</span><span style="color:#5c2699;">UILabel</span><span style="color:#000000;"> </span><span style="color:#2e0d6e;">alloc</span><span style="color:#000000;">]</span><span style="color:#2e0d6e;">init</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">secondaryLabel</span>.textAlignment = <span style="color:#2e0d6e;">UITextAlignmentLeft</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#3f6e74;">secondaryLabel</span><span style="color:#000000;">.font = [</span><span style="color:#5c2699;">UIFont</span><span style="color:#000000;"> </span>systemFontOfSize<span style="color:#000000;">:</span><span style="color:#1c00cf;">8</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">myImageView</span> = [[<span style="color:#5c2699;">UIImageView</span> <span style="color:#2e0d6e;">alloc</span>]<span style="color:#2e0d6e;">init</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span>.contentView <span style="color:#2e0d6e;">addSubview</span>:<span style="color:#3f6e74;">primaryLabel</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span>.contentView <span style="color:#2e0d6e;">addSubview</span>:<span style="color:#3f6e74;">secondaryLabel</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span>.contentView <span style="color:#2e0d6e;">addSubview</span>:<span style="color:#3f6e74;">myImageView</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"> </span>return<span style="color:#000000;"> </span>self<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>We create the three elements and added them to the contentView of our cell. Also don&#8217;t forget to synthesize all the three elements as we are going to access these elements from other classes.</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">@synthesize</span> primaryLabel,secondaryLabel,myImageView;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">
</div>
<div>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:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)layoutSubviews {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"> [</span><span style="color:#aa0d91;">super</span><span style="color:#000000;"> </span>layoutSubviews<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">CGRect</span> contentRect = <span style="color:#aa0d91;">self</span>.contentView.bounds;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">CGFloat</span> boundsX = contentRect.<span style="color:#5c2699;">origin</span>.<span style="color:#5c2699;">x</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">CGRect</span> frame;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>frame= <span style="color:#2e0d6e;">CGRectMake</span>(boundsX+<span style="color:#1c00cf;">10</span> ,<span style="color:#1c00cf;">0</span>, <span style="color:#1c00cf;">50</span>, <span style="color:#1c00cf;">50</span>);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">myImageView</span>.frame = frame;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>frame= <span style="color:#2e0d6e;">CGRectMake</span>(boundsX+<span style="color:#1c00cf;">70</span> ,<span style="color:#1c00cf;">5</span>, <span style="color:#1c00cf;">200</span>, <span style="color:#1c00cf;">25</span>);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">primaryLabel</span>.frame = frame;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>frame= <span style="color:#2e0d6e;">CGRectMake</span>(boundsX+<span style="color:#1c00cf;">70</span> ,<span style="color:#1c00cf;">30</span>, <span style="color:#1c00cf;">100</span>, <span style="color:#1c00cf;">15</span>);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">secondaryLabel</span>.frame = frame;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>You can do anything in this method to define the lay out of cell. I have simply assigned frames to all the elements.</div>
<div>You can also find a method in CustomCell.m</div>
<div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">- (<span style="color: #aa0d91; ">void</span>)setSelected:(<span style="color: #aa0d91; ">BOOL</span>)selected animated:(<span style="color: #aa0d91; ">BOOL</span>)animated {</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">[<span style="color: #aa0d91; ">super</span> <span style="color: #2e0d6e; ">setSelected</span>:selected <span style="color: #2e0d6e; ">animated</span>:animated];</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: #007400; "><span style="color: #000000; "> </span>// Configure the view for the selected state</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">}</p>
</div>
<div>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.</div>
<div>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.</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color: #643820;"><br />
</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#643820;">#import </span>&#8220;CustomCell.h&#8221;</p>
</div>
<div>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:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">NSInteger</span>)tableView:(<span style="color:#5c2699;">UITableView</span> *)tableView numberOfRowsInSection:(<span style="color:#5c2699;">NSInteger</span>)section {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">return</span> <span style="color:#1c00cf;">5</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
</div>
<div>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:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">UITableViewCell</span> *)tableView:(<span style="color:#5c2699;">UITableView</span> *)tableView cellForRowAtIndexPath:(<span style="color:#5c2699;">NSIndexPath</span> *)indexPath {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">static</span> <span style="color:#5c2699;">NSString</span> *CellIdentifier = <span style="color:#c41a16;">@&#8221;Cell&#8221;</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#3f6e74;">CustomCell</span> *cell = [tableView <span style="color:#2e0d6e;">dequeueReusableCellWithIdentifier</span>:CellIdentifier];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">if</span> (cell == <span style="color:#aa0d91;">nil</span>) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"> cell = [[[</span><span style="color:#3f6e74;">CustomCell</span><span style="color:#000000;"> </span>alloc<span style="color:#000000;">] </span>initWithFrame<span style="color:#000000;">:</span><span style="color:#5c2699;">CGRectZero</span><span style="color:#000000;"> </span>reuseIdentifier<span style="color:#000000;">:CellIdentifier] </span>autorelease<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"> </span>// Set up the cell&#8230;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">switch</span> (indexPath.row) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">0</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span>@&#8221;Meeting on iPhone Development&#8221;<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span>secondaryLabel<span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span><span style="color:#c41a16;">@&#8221;Sat 10:30&#8243;</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>cell.<span style="color:#3f6e74;">myImageView</span>.image = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>:<span style="color:#c41a16;">@"meeting_color.png"</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>break<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">1</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span>@&#8221;Call With Client&#8221;<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span>secondaryLabel<span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span><span style="color:#c41a16;">@&#8221;Planned&#8221;</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>cell.<span style="color:#3f6e74;">myImageView</span>.image = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>:<span style="color:#c41a16;">@"call_color.png"</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">break</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">2</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span>@&#8221;Appointment with Joey&#8221;<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span>secondaryLabel<span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span><span style="color:#c41a16;">@&#8221;2 Hours&#8221;</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>cell.<span style="color:#3f6e74;">myImageView</span>.image = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>:<span style="color:#c41a16;">@"calendar_color.png"</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>break<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">3</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span>@&#8221;Call With Client&#8221;<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span>secondaryLabel<span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span><span style="color:#c41a16;">@&#8221;Planned&#8221;</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>cell.<span style="color:#3f6e74;">myImageView</span>.image = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>:<span style="color:#c41a16;">@"call_color.png"</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>break<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">4</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span><span style="color:#3f6e74;">primaryLabel</span><span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span>@&#8221;Appointment with Joey&#8221;<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span>secondaryLabel<span style="color:#000000;">.</span><span style="color:#5c2699;">text</span><span style="color:#000000;"> = </span><span style="color:#c41a16;">@&#8221;2 Hours&#8221;</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>cell.<span style="color:#3f6e74;">myImageView</span>.image = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>:<span style="color:#c41a16;">@"calendar_color.png"</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>break<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>default<span style="color:#000000;">:</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>break<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">return</span> cell;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>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.</div>
<div>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:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">CGFloat</span>)tableView:(<span style="color:#5c2699;">UITableView</span> *)tableView heightForRowAtIndexPath:(<span style="color:#5c2699;">NSIndexPath</span> *)indexPath</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "><span style="color:#000000;"><span style="white-space:pre"> </span></span>return<span style="color:#000000;"> </span><span style="color:#1c00cf;">50</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
</div>
<div>Let me know if I have been missing something here.</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=284</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>iPhone Tutorial: Application Preferences &#8211; Accessing Preferences from code</title>
		<link>http://blog.webscale.co.in/?p=277</link>
		<comments>http://blog.webscale.co.in/?p=277#comments</comments>
		<pubDate>Wed, 22 Apr 2009 13:44:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=277</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<div>Following are some of the things covered:</div>
<div>
<ol>
<li>Reading Preferences</li>
<li>Editing Preferences</li>
<li>Custom UITableView</li>
<li>Wizard</li>
</ol>
<p>The Wizard will finally look like this:</p></div>
<div><a href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqITdgJATI/AAAAAAAAAOM/D8IXNy-6D14/s1600-h/screen-capture-12.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"> <img id="BLOGGER_PHOTO_ID_5299197779473137970" style="cursor: pointer; width: 205px; height: 400px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqITdgJATI/AAAAAAAAAOM/D8IXNy-6D14/s400/screen-capture-12.jpg" border="0" alt="" /></a></div>
<div>You should read the following posts for basics</div>
<div><a href="http://blog.webscale.co.in/?p=268" target="_blank">Application Preferences &#8211; Part 1 </a></div>
<div><a href="http://blog.webscale.co.in/?p=274" target="_blank">Application Preferences &#8211; Part 2</a></div>
<p><span id="more-277"></span></p>
<div>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:</div>
<div><span style="white-space:pre"> </span><span style="font-weight: bold;"><span style="font-style: italic;">NSUserDefaults *user = [NSUserDefaults standardUserDefault];</span></span></div>
<div><span style="white-space:pre"><span style="font-weight: bold;"><span style="font-style: italic;"> </span></span></span><span style="font-weight: bold;"><span style="font-style: italic;">[user boolForKey:]</span></span></div>
<div><span style="white-space:pre"><span style="font-weight: bold;"><span style="font-style: italic;"> </span></span></span><span style="font-weight: bold;"><span style="font-style: italic;">[user stringForKey:]</span></span></div>
<div><span style="white-space:pre"><span style="font-weight: bold;"><span style="font-style: italic;"> </span></span></span><span style="font-weight: bold;"><span style="font-style: italic;">[user setBool:(BOOL) forKey:] </span></span></div>
<div><span style="font-style: italic; font-weight: bold;"> </span></div>
<div></div>
<div>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.</div>
<div>Before accessing preferences, we need to setup the view for the wizard. So open SetupWizard.h and add the following code:</div>
<div>`</div>
<div><a href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqDI2ZzWNI/AAAAAAAAANs/w26ba-N6SHM/s1600-h/screen-capture-7.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5299192099620739282" style="cursor: pointer; width: 400px; height: 134px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYqDI2ZzWNI/AAAAAAAAANs/w26ba-N6SHM/s400/screen-capture-7.jpg" border="0" alt="" /></a></div>
<div>`</div>
<div>Here we have created some UI elements which are similar to the ones we have in our application preferences if you remember.</div>
<div>Since we will be using a table view , we have included the tableview delegate and datasource in interface declaration, which also includes <span style="font-weight: bold;"><span style="font-style: italic;">UITextFieldDelegate </span><span style="font-weight: normal;">. We will see later why we have used it.</span></span></div>
<div>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.</div>
<div></div>
<div>For now open SetupWizard.m and add the following code inside loadView method:</div>
<div>`</div>
<div><a href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqEsW06sUI/AAAAAAAAAN8/BVe4aHxr66E/s1600-h/screen-capture-1.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5299193809131450690" style="cursor: pointer; width: 380px; height: 400px;" src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqEsW06sUI/AAAAAAAAAN8/BVe4aHxr66E/s400/screen-capture-1.jpg" border="0" alt="" /></a></div>
<div>`</div>
<div>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.</div>
<div>Important things to note in this code are: we need to have a method named &#8220;save&#8221; which we have added as a target to the button.</div>
<div></div>
<div>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.</div>
<div></div>
<div>Before implementing save method, we should not forget we have a tableView added into the view so we have to implement it&#8217;s protocol methods. Add the following code in SetupWizard.m:</div>
<div>`</div>
<div><a href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYqH3zTxekI/AAAAAAAAAOE/7Tr7OQ1FV1c/s1600-h/screen-capture-4.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5299197304290507330" style="cursor: pointer; width: 400px; height: 285px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYqH3zTxekI/AAAAAAAAAOE/7Tr7OQ1FV1c/s400/screen-capture-4.jpg" border="0" alt="" /></a></div>
<div>`</div>
<div>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.</div>
<div>`</div>
<div><a href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqJvG9nZJI/AAAAAAAAAOU/iqRwUIuWAro/s1600-h/screen-capture-10.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5299199353970713746" style="cursor: pointer; width: 198px; height: 400px;" src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqJvG9nZJI/AAAAAAAAAOU/iqRwUIuWAro/s400/screen-capture-10.jpg" border="0" alt="" /></a></div>
<div>`</div>
<div>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:</div>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYqK4R3MB6I/AAAAAAAAAOc/XyUrQhewThU/s1600-h/screen-capture-5.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5299200611026995106" style="cursor: pointer; width: 400px; height: 121px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYqK4R3MB6I/AAAAAAAAAOc/XyUrQhewThU/s400/screen-capture-5.jpg" border="0" alt="" /></a></div>
<div>`</div>
<div>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&#8217;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.</div>
<div></div>
<div>Now we are going to implement the most awaited &#8220;Save&#8221; method where we will be accessing preferences. Add the following code in SetupWizard.m</div>
<div>`</div>
<div><a href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqElK8T9nI/AAAAAAAAAN0/67RK7H5JZQw/s1600-h/screen-capture-2.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5299193685682157170" style="cursor: pointer; width: 400px; height: 183px;" src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYqElK8T9nI/AAAAAAAAAN0/67RK7H5JZQw/s400/screen-capture-2.jpg" border="0" alt="" /></a></div>
<div>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:</div>
<div>`</div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)tableView:(<span style="color:#5c2699;">UITableView</span> *)tableView didSelectRowAtIndexPath:(<span style="color:#5c2699;">NSIndexPath</span> *)indexPath {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>SetupWizard<span style="color:#000000;"> *wizard = [[</span>SetupWizard<span style="color:#000000;"> </span><span style="color:#2e0d6e;">alloc</span><span style="color:#000000;">]</span><span style="color:#2e0d6e;">init</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span>.navigationController <span style="color:#2e0d6e;">pushViewController</span>:wizard <span style="color:#2e0d6e;">animated</span>:<span style="color:#aa0d91;">YES</span>];</p>
<div><span style=" ;font-family:Monaco;font-size:10px;">}</span></div>
<div>`</div>
<div>Now if you run build and run the project, you can see the wizard by clicking on any row in the table.</div>
<div><span style="font-weight: bold;">You can download the whole code till now from </span><a href="http://rapidshare.com/files/195954874/MyTestProject.zip"><span style="font-weight: bold;">here</span></a><span style="font-weight: bold;"> </span></div>
<div><span style="font-weight: bold;"> </span></div>
<div>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 :</div>
<div>`</div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">-(<span style="color:#aa0d91;">void</span>)loadPreferences</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#5c2699;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>NSUserDefaults<span style="color:#000000;"> *userDefaults = [</span>NSUserDefaults<span style="color:#000000;"> </span><span style="color:#2e0d6e;">standardUserDefaults</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#3f6e74;">textField</span> <span style="color:#2e0d6e;">setText</span>: [userDefaults <span style="color:#2e0d6e;">stringForKey</span>:<span style="color:#c41a16;">@"url"</span>]];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">if</span>([userDefaults <span style="color:#2e0d6e;">integerForKey</span>:<span style="color:#c41a16;">@"whichNumber"</span>] == <span style="color:#1c00cf;">0</span>)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#3f6e74;">cell1</span><span style="color:#000000;">.</span><span style="color:#5c2699;">accessoryType</span><span style="color:#000000;"> = </span>UITableViewCellAccessoryCheckmark<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>else</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#3f6e74;">cell2</span><span style="color:#000000;">.</span><span style="color:#5c2699;">accessoryType</span><span style="color:#000000;"> = </span>UITableViewCellAccessoryCheckmark<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#3f6e74;">sw</span> <span style="color:#2e0d6e;">setOn</span>:[userDefaults <span style="color:#2e0d6e;">boolForKey</span>:<span style="color:#c41a16;">@"switch1"</span>]];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#3f6e74;">slider</span> <span style="color:#2e0d6e;">setValue</span>:[userDefaults doubleForKey:<span style="color:#c41a16;">@"slider_preference"</span>]];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div>`</div>
<div>and call this method from viewDidLoad like this:</div>
<div>`</div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)viewDidLoad {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#26474b;"><span style="color:#000000;"><span style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">self</span><span style="color:#000000;"> </span>loadPreferences<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div>`</div>
<div>Now if you build and run the application, every time you will see the previous configurations showing up in the wizard.</div>
<div></div>
<div>Let me know if I have been missing anything.</div>
<div></div>
<div>`</div>
<div>`</div>
<div></div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=277</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhone Tutorial: Application Preferences &#8211; Using a Child Pane</title>
		<link>http://blog.webscale.co.in/?p=274</link>
		<comments>http://blog.webscale.co.in/?p=274#comments</comments>
		<pubDate>Wed, 22 Apr 2009 13:36:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=274</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>In this post I will be using PSChildPaneSpecifier in the application preferences.</p>
<p>You should read part 1 of this post if you are not familiar with application preferences. You can find it <a href="http://blog.webscale.co.in/?p=268" target="_blank">here</a> .<br />
 </p>
<div>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.</div>
<p><span id="more-274"></span></p>
<div>
A child pane is nothing but another plist file. So to start with, open the same project &#8220;MyTestProject&#8221;, right click on Settings.bundle and select &#8220;add new&#8221;. From the &#8220;Other&#8221; tab select plist file as shown below:</p>
<div><a href="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYhy-CgVdGI/AAAAAAAAAM0/mKdIH2uP6uk/s1600-h/screen-capture.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298611371751339106" style="cursor: pointer; width: 400px; height: 295px;" src="http://4.bp.blogspot.com/_pV2VnLyRiRE/SYhy-CgVdGI/AAAAAAAAAM0/mKdIH2uP6uk/s400/screen-capture.jpg" border="0" alt="" /></a></div>
<div>Name the file as &#8220;Child.plist&#8221;. <span style="font-weight: bold;">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.</span></div>
<div><span style="font-weight: bold;"><br />
</span></div>
<div>To do so, open Terminal and navigate to your projects directory. Execute &#8220;ls&#8221; on shell to cross verify that you are in the correct directory. Following should appear on the Terminal:</div>
<div><a href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhy-dn_4VI/AAAAAAAAAM8/lM1kabmq3hQ/s1600-h/screen-capture-1.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298611379031236946" style="cursor: pointer; width: 400px; height: 290px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhy-dn_4VI/AAAAAAAAAM8/lM1kabmq3hQ/s400/screen-capture-1.jpg" border="0" alt="" /></a></div>
<div>Now copy child.plist file into the Settings.bundle by following command: &#8220;<span style="font-weight: bold;"><span style="font-style: italic;">cp child.plist Settings.bundle</span></span>&#8220;. Cross verify by navigating into Settings.bundle directory and executing &#8220;ls&#8221;. child.plist file should show up.</div>
<div>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:</div>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UnuP2I/AAAAAAAAANE/cjuw9OFlVgg/s1600-h/screen-capture-2.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298611376614162274" style="cursor: pointer; width: 400px; height: 231px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UnuP2I/AAAAAAAAANE/cjuw9OFlVgg/s400/screen-capture-2.jpg" border="0" alt="" /></a></div>
<div>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.</div>
<div><a href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYh0D9h3L4I/AAAAAAAAANc/vKfSAjGj4FY/s1600-h/screen-capture-3.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298612573006409602" style="cursor: pointer; width: 400px; height: 185px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYh0D9h3L4I/AAAAAAAAANc/vKfSAjGj4FY/s400/screen-capture-3.jpg" border="0" alt="" /></a></div>
<div>Build and run the application , go to the settings and select your project MyTestProject. It shold look similar to the following:</div>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UemkZI/AAAAAAAAANM/EnJ5CSDVJwM/s1600-h/screen-capture-4.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298611376575910290" style="cursor: pointer; width: 197px; height: 400px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhy-UemkZI/AAAAAAAAANM/EnJ5CSDVJwM/s400/screen-capture-4.jpg" border="0" alt="" /> </a><a href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhy-kI0L-I/AAAAAAAAANU/S2UDJFCB640/s1600-h/screen-capture-5.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298611380779495394" style="cursor: pointer; width: 199px; height: 400px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhy-kI0L-I/AAAAAAAAANU/S2UDJFCB640/s400/screen-capture-5.jpg" border="0" alt="" /></a></div>
<div>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.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=274</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPhone Tutorial: Application Preferences &#8211; Part 1</title>
		<link>http://blog.webscale.co.in/?p=268</link>
		<comments>http://blog.webscale.co.in/?p=268#comments</comments>
		<pubDate>Wed, 22 Apr 2009 13:29:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=268</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>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 your application name to be listed inside Settings, you need to follow the procedure.</p>
<div>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.</div>
<div>Following is a list of options we have for UI elements that we can provide:</div>
<div>
<ol>
<li>PSTitleValueSpecifier: Used to write titles, similar to UILabel</li>
<li><span style="white-space: pre;">PSTextFieldSpecifier: Similar to UITextField</span></li>
<li><span style="white-space: pre;">PSToggleSwitchSpecifier: A toggle switch which can be ON or OFF</span></li>
<li><span style="white-space: pre;">PSSliderSpecifier: A slider which can be used to provide a value bw MAX and MIN</span></li>
<li><span style="white-space: pre;">PSMultiValueSpecifier: Shows multiple values from which user can select one.</span></li>
<li><span style="white-space: pre;">PSGroupSpecifier: Very important for layout (discussed later).</span></li>
<li><span style="white-space: pre;">PSChildPaneSpecifier: When you need to have another page of configurations.</span></li>
</ol>
</div>
<p><span id="more-268"></span></p>
<div>All these elements can be used in the settings and you can read as well as manipulate them from your code.</div>
<div>Lets start the procedure. Open the same project &#8220;MyTestProject&#8221; 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.</div>
<div><a href="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhUOs4yJOI/AAAAAAAAAMM/D_t8ZeFTk0Q/s1600-h/screen-capture.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298577573145617634" style="cursor: pointer; width: 400px; height: 298px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/SYhUOs4yJOI/AAAAAAAAAMM/D_t8ZeFTk0Q/s400/screen-capture.jpg" border="0" alt="" /></a></div>
<div>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.</div>
<div>By default it should look like this:</div>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1mAtPI/AAAAAAAAAMk/WNGW6sYcg3E/s1600-h/screen-capture-3.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298577575482799346" style="cursor: pointer; width: 400px; height: 140px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1mAtPI/AAAAAAAAAMk/WNGW6sYcg3E/s400/screen-capture-3.jpg" border="0" alt="" /></a></div>
<div>Right click on Preference Specifier and select &#8220;cut&#8221;. 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  &#8220;+&#8221; button on the right side of the table and in place of &#8220;new Item&#8221; type PreferenceSpecifiers. In the type field corresponding to PreferenceSpecifiers, select &#8220;Array&#8221;.</div>
<div>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 &#8220;+&#8221; image on right has now changed and it shows 3 lines. Click on it to add a child which will automatically be named as &#8220;Item 1&#8243;. In the Type select &#8220;Dictionary&#8221;.</div>
<div>Now expand &#8220;Item 1&#8243; and add a child element to it, name it as &#8220;Title&#8221;. Type should be &#8220;String&#8221; and in the Value write &#8220;URL&#8221;.</div>
<div>Add more childs and make the plist file look like this:</div>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUOnvhaPI/AAAAAAAAAMU/5ckfM9-dSbc/s1600-h/screen-capture-1.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298577571764594930" style="cursor: pointer; width: 400px; height: 138px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUOnvhaPI/AAAAAAAAAMU/5ckfM9-dSbc/s400/screen-capture-1.jpg" border="0" alt="" /></a></div>
<div><span style="font-weight: bold;">Now Click on the arrow against &#8220;Item 1&#8243; to hide its child elements, click on &#8220;Item 1&#8243; (not on the arrow) and click on &#8220;+&#8221; button on right.</span> This should show &#8220;Item 2&#8243; below &#8220;Item 1&#8243;. 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.</div>
<div>Add more items to make it look like this:</div>
<div><a href="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhUOxfLvmI/AAAAAAAAAMc/4U8BErBUWHc/s1600-h/screen-capture-2.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298577574380420706" style="cursor: pointer; width: 400px; height: 305px;" src="http://1.bp.blogspot.com/_pV2VnLyRiRE/SYhUOxfLvmI/AAAAAAAAAMc/4U8BErBUWHc/s400/screen-capture-2.jpg" border="0" alt="" /></a></div>
<div>Now build and run your project, go to Settings and find you applications&#8217; name there, clicking on it should show a screen like this:</div>
<div><a href="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1PUtiI/AAAAAAAAAMs/yM2pd2WxU-U/s1600-h/screen-capture-4.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5298577575387641378" style="cursor: pointer; width: 213px; height: 400px;" src="http://2.bp.blogspot.com/_pV2VnLyRiRE/SYhUO1PUtiI/AAAAAAAAAMs/yM2pd2WxU-U/s400/screen-capture-4.jpg" border="0" alt="" /></a></div>
<div>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.</div>
<div>Do not forget to mention name of your project &#8220;MyTestProject&#8221; against &#8220;Title&#8221;, the second field from top in the pList file.</div>
<div><span style="font-weight: bold;">A</span><span style="font-weight: bold;">n important thing to remember: &#8220;+&#8221; button in plist file adds a sibbling and the button with 3 lines adds a child.</span></div>
<div>If you faced any problem in creating child elements or new Items at the specific place in the plist file, don&#8217;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.</div>
<div>Topics of next post:</div>
<div>
<ol>
<li>Using PSChildPaneSpecifier and adding rest of the types.</li>
<li>Accessing application preferences from inside your code</li>
<li>Changing preferences from your code.</li>
</ol>
</div>
<div>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).</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=268</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hibernate Collections</title>
		<link>http://blog.webscale.co.in/?p=132</link>
		<comments>http://blog.webscale.co.in/?p=132#comments</comments>
		<pubDate>Wed, 15 Apr 2009 08:49:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[persistence]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=132</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>An object by itself is intensely uninteresting.Objects contribute to the behavior of a system by collaborating with one another.One of relationship aspects between Objects can be represented by Association.</p>
<p>When we bring in Cardinality in Association we get One-to-One, One-to-Many and Many-to-Many.In later two One-to-Many and Many-to-Many we use Collection to represent many Side.For example: An Order have many OrderDetail&#8217;s.</p>
<p>We have these associations represented in Relational DBMS using foreign keys.So from any O-R framework we expect that to take care of these associations in smartest way possible.As these can easily become a performance bottle neck for the application.Some time you may end up loading lot of Data into memory, and sad part is you are never going to use them. <span id="more-132"></span></p>
<p>So here is what i think we expect from Collections in O-R:</p>
<p>1. Ability to map the Collections to DB</p>
<p>2. Ability to Load them</p>
<p>3. Ability to traverse smartly</p>
<p>4. Ability to add elements to  collection</p>
<p>5. Ability to remove elements from collection</p>
<p>Some points from above I will try to explain in detail from Hibernate Perspective.I will be skipping mapping part that is well explained in <a href="http://www.hibernate.org/hib_docs/reference/en/html/collections.html">Hibernate Reference Documentation</a>.</p>
<p>Let&#8217;s start with which collections we generally want to map :</p>
<p>1. Set</p>
<p>2. List</p>
<p>3. Map</p>
<p>there could be special cases where we want to preserve Order (which can be insertion or sort)</p>
<p>1. SortedSet</p>
<p>2. LinkedList</p>
<p>3. SortedMap</p>
<p>One other kind of collection can be an array.But generally we dont use them in our domain models.Well there are reasons from O-R point also against them like lazy-loading,optimized dirty checking cannot be achieved as we cannot wrap them or byte code instrument them.</p>
<h5><strong>Collections and Hibernate</strong></h5>
<p>Persistent collections are treated as value objects by Hibernate. ie. they have  no independent existence beyond the object holding a reference to them. Unlike  instances of entity classes, they are automatically deleted when unreferenced  and automatically become persistent when held by a persistent object.  Collections can be passed between different objects (change &#8220;roles&#8221;) and this  might cause their elements to move from one database table to another.</p>
<p>Hibernate &#8220;wraps&#8221; a java collection in an instance of PersistentCollection. This  mechanism is designed to support tracking of changes to the collection&#8217;s  persistent state and lazy instantiation of collection elements. The downside is  that only certain abstract collection types are supported and any extra  semantics are lost. Now before jumping in PersistentCollection code lets try to think what do we need this wrapper to do:</p>
<p><strong>Lazy Loading</strong></p>
<p>          It need to load actual data only &#8220;when&#8221; needed. So what is this &#8220;when&#8221;</p>
<p>                  a.) Doing  size() operation and isEmpty Check</p>
<p>                            Whenever this operation will be invoked PersistentCollection will check if collection has been loaded or not.If not then it will have another check whether this collection has been mapped as extra-lazy or not. If its extra-lazy then it will only do a &#8220;select count&#8221;  sql to get the size rather then loading the collection. If its not marked extra-lazy then it will load the collection from database and execute operation on actual collection.</p>
<p>                 b.) Doing a contains check</p>
<p>                          For this operation also we need to check whether Collection has been loaded or not. If its not loaded and marked extra-lazy then it will do a &#8220;select 1 &#8221; to find out whether this element exists or not.So this will save us loading of the collection and a simple sql will suffice.If its not marked extra-lazy then it will load the collection and execute operation on actual collection.</p>
<p>                  c.) Getting iterator                  </p>
<p>                         For this operation no matter whether its marked extra-lazy or not it will need to initialize the collection from DB. But here it cannot return iterator of actual Collection.It will create a proxy Iterator.As it will need to keep track of remove operation on iterator.</p>
<p>                  d.) Adding some element in collection</p>
<p>                       This operation will have different implementations based on whether we are having a List or Set. As Set cannot allow duplicates. So question finally boils down on can we do an add without loading the collection. Well yes for List we can do that.But for Set we need to do a contains check internally, whether that element already exists or not which is similar to contains check i described above. </p>
<p>                       If collection is loaded then we can directly do add on the collection and mark the collection dirty. Otherwise it queues the operation to be synced with DB at later stage. Again some kind of lazy behavior. Hibernate calls these operations DelayedOperations and execute them immediatedly after loading the collection whenever its is loaded.</p>
<p>                  e.) Removing some element from collection</p>
<p>                      This opertaion implementation is going to be similar to a Set add. As we need to check whether this element actually exists in DB or not. So if its marked extra-lazy we need to do existence check in DB without loaidng the collection. If its not marked then we need to load the collection and then do the operation on actual collection. Similar to add this can also have lazy behavior and it can be delayed till we load the collection by queuing this operation. Also it needs to mark the collection dirty after this opertaion.</p>
<p>                 f.)  clear operation on collection</p>
<p>                        This opertaion implementation is very simple. If Collection has not been initialized yet.(It needs additional check whether its an Inverse Collection and whether its Orphan Delete or not). It will queue the operation. </p>
<p>                         Otherwise it will execute the operation. Here hibernate does on smart check of isEmpty as if collection isEmpty it doesn need to clear. As without doing this check if it does clear then it would have needed to mark the collection dirty which would have been wrong. As clearing an Empty collection is not making Collection dirty.</p>
<p>                   What is &#8220;Dirty&#8221; ?</p>
<p>                   I referred to marking Collection dirty a lot in all operations. What affects does this have ? dirty Field will be used by Flush operations on Session, flush of the Entity Holding the Collection. And this flag is the one which is going to trigger sync of Collection state with the DB.</p>
<p>So we discussed two things one is Lazy Loading of Collection and other is Delayed Operations.</p>
<p>There are lot of details which i am going to discuss for Collection treatment in Hibernate. Till now i discussed Lazy Loading. This is going to be a series of blog Entries on Hibernate Collections. Next Articles in the series ares going to be:</p>
<p>1.  Fetching Collections from DB</p>
<p>2. Sync of Collection State with DB</p>
<p>3. Collections and Caching</p>
<p>4. Treatment of Cardinality in Collection</p>
<p>5. Different kind of Collections</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=132</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>iPhone Tutorial: Adding a Calendar</title>
		<link>http://blog.webscale.co.in/?p=244</link>
		<comments>http://blog.webscale.co.in/?p=244#comments</comments>
		<pubDate>Thu, 09 Apr 2009 11:35:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://blog.webscale.co.in/?p=244</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'Array' was given in <b>/home/psingh/public_html/blog/wp-includes/plugin.php</b> on line <b>166</b><br />
]]></description>
			<content:encoded><![CDATA[<p>In this post I will be creating a calendar, which could reused in an any native application.</p>
<div>I used the calendar source from <a href="http://tinyurl.com/5k2boy">here</a> and modified it a little bit to suit my requirements.</div>
<div>You can find the modified code from my project here: <a href="http://rapidshare.com/files/219229288/CalendarTest.zip">DOWNLOAD PROJECT</a></div>
<div>The final screen should look like this:</div>
<div><a href="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd3YIfyCvTI/AAAAAAAAAS8/rdN0UDPpr6M/s1600-h/screen-capture-4.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}">                             <img id="BLOGGER_PHOTO_ID_5322647975103741234" style="cursor: pointer; width: 206px; height: 400px;" src="http://3.bp.blogspot.com/_pV2VnLyRiRE/Sd3YIfyCvTI/AAAAAAAAAS8/rdN0UDPpr6M/s400/screen-capture-4.jpg" border="0" alt="" /></a></div>
<div>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.</div>
<div>
<div>For basics, refer my previous posts</div>
<div>
<ul>
<li><a href="http://blog.webscale.co.in/?p=143">Simple Hello World Application</a></li>
<li><a href="http://blog.webscale.co.in/?p=150">Navigating from one view to another</a></li>
<li><a href="http://blog.webscale.co.in/?p=150">Creating a UITableView programmatically</a></li>
<li><a href="http://blog.webscale.co.in/?p=154">Customizing Header View of table</a></li>
<li><a href="http://blog.webscale.co.in/?p=205">Using SQLite3 database</a></li>
<li><a href="http://blog.webscale.co.in/?p=240" target="_blank">Native Address Book like Screen</a></li>
<li><a href="http://blog.webscale.co.in/?p=228" target="_blank">Adding a Search Bar in tableView</a></li>
</ul>
</div>
</div>
<p><span id="more-244"></span></p>
<div>Open the project CalendarTest in xCode. You will find a folder Calendar containing some 20 files.</div>
<div>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.</div>
<div>Open CalendarTestView.m and find the following code:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)loadView {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">super</span><span style="color:#000000;"> </span>loadView<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">calendarView</span> = [[[<span style="color:#3f6e74;">KLCalendarView</span> <span style="color:#2e0d6e;">alloc</span>] <span style="color:#26474b;">initWithFrame</span>:<span style="color:#2e0d6e;">CGRectMake</span>(<span style="color:#1c00cf;">0.0f</span>, <span style="color:#1c00cf;">0.0f</span>,  <span style="color:#1c00cf;">320.0f</span>, <span style="color:#1c00cf;">360</span>) <span style="color:#26474b;">delegate</span>:<span style="color:#aa0d91;">self</span>] <span style="color:#2e0d6e;">autorelease</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#3f6e74;">myTableView</span><span style="color:#000000;"> = [[</span><span style="color:#5c2699;">UITableView</span><span style="color:#000000;"> </span>alloc<span style="color:#000000;">]</span>initWithFrame<span style="color:#000000;">:</span>CGRectMake<span style="color:#000000;">(</span><span style="color:#1c00cf;">0</span><span style="color:#000000;">,</span><span style="color:#1c00cf;">260</span><span style="color:#000000;">,</span><span style="color:#1c00cf;">320</span><span style="color:#000000;">,</span><span style="color:#1c00cf;">160</span><span style="color:#000000;">) </span>style<span style="color:#000000;">:</span>UITableViewStylePlain<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>myTableView<span style="color:#000000;">.</span><span style="color:#5c2699;">dataSource</span><span style="color:#000000;"> = </span><span style="color:#aa0d91;">self</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>myTableView<span style="color:#000000;">.</span><span style="color:#5c2699;">delegate</span><span style="color:#000000;"> = </span><span style="color:#aa0d91;">self</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">UIView</span> *myHeaderView = [[<span style="color:#5c2699;">UIView</span> <span style="color:#2e0d6e;">alloc</span>] <span style="color:#2e0d6e;">initWithFrame</span>:<span style="color:#2e0d6e;">CGRectMake</span>(<span style="color:#1c00cf;">0</span>,<span style="color:#1c00cf;">0</span>,<span style="color:#3f6e74;">myTableView</span>.frame.<span style="color:#5c2699;">size</span>.<span style="color:#5c2699;">width</span> , <span style="color:#1c00cf;">20</span>)];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>myHeaderView.backgroundColor = [<span style="color:#5c2699;">UIColor</span> <span style="color:#2e0d6e;">grayColor</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#3f6e74;">myTableView</span> <span style="color:#2e0d6e;">setTableHeaderView</span>:myHeaderView];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span>.view <span style="color:#2e0d6e;">addSubview</span>:<span style="color:#3f6e74;">myTableView</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">self</span><span style="color:#000000;">.view </span><span style="color:#2e0d6e;">addSubview</span><span style="color:#000000;">:</span>calendarView<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">self</span><span style="color:#000000;">.view </span>bringSubviewToFront<span style="color:#000000;">:</span><span style="color:#3f6e74;">myTableView</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
<div>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.</div>
</div>
<div>Now find the Calendar Delegate methods:</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)calendarView:(<span style="color:#3f6e74;">KLCalendarView</span> *)<span style="color:#3f6e74;">calendarView</span> tappedTile:(<span style="color:#3f6e74;">KLTile</span> *)aTile{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span></span><span style="color:#2e0d6e;">NSLog</span><span style="color:#000000;">(</span>@&#8221;Date Selected is %@&#8221;<span style="color:#000000;">,[aTile </span><span style="color:#2e0d6e;">date</span><span style="color:#000000;">]);</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>[aTile <span style="color:#26474b;">flash</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">if</span>(<span style="color:#3f6e74;">tile</span> == <span style="color:#aa0d91;">nil</span>)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">tile</span> = aTile;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>else</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#26474b;"><span style="color:#000000;"><span style="white-space:pre"> </span>[</span><span style="color:#3f6e74;">tile</span><span style="color:#000000;"> </span>restoreBackgroundColor<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">tile</span> = aTile;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span><span style="white-space: pre; "> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>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.</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#3f6e74;">KLTile</span> *)calendarView:(<span style="color:#3f6e74;">KLCalendarView</span> *)<span style="color:#3f6e74;">calendarView</span> createTileForDate:(<span style="color:#3f6e74;">KLDate</span> *)date{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#3f6e74;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>CheckmarkTile<span style="color:#000000;"> *</span>tile<span style="color:#000000;"> = [[</span>CheckmarkTile<span style="color:#000000;"> </span><span style="color:#2e0d6e;">alloc</span><span style="color:#000000;">] </span><span style="color:#2e0d6e;">init</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>//tile.checkmarked = YES;//based on any condition you can checkMark a tile</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>return<span style="color:#000000;"> </span><span style="color:#3f6e74;">tile</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>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.</div>
<div>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.</div>
<div>For example I have a meeting on 4th of current month. You can check if tile.date == 4th then check-mark the tile.</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)didChangeMonths{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#5c2699;">UIView</span> *clip = <span style="color:#3f6e74;">calendarView</span>.superview;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">if</span> (!clip)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">return</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#5c2699;">CGRect</span> f = clip.frame;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#26474b;"><span style="color:#000000;"> </span><span style="color:#5c2699;">NSInteger</span><span style="color:#000000;"> weeks = [</span><span style="color:#3f6e74;">calendarView</span><span style="color:#000000;"> </span>selectedMonthNumberOfWeeks<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#5c2699;">CGFloat</span> adjustment = <span style="color:#1c00cf;">0.f</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">switch</span> (weeks) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">4</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">adjustment = (<span style="color:#1c00cf;">92</span>/<span style="color:#1c00cf;">321</span>)*<span style="color:#1c00cf;">360</span>+<span style="color:#1c00cf;">30</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">break</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">5</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">adjustment = (<span style="color:#1c00cf;">46</span>/<span style="color:#1c00cf;">321</span>)*<span style="color:#1c00cf;">360</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">break</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">6</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">adjustment = <span style="color:#1c00cf;">0.f</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">break</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">default</span>:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">break</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">f.<span style="color:#5c2699;">size</span>.<span style="color:#5c2699;">height</span> = <span style="color:#1c00cf;">360</span> &#8211; adjustment;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">clip.frame = f;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">CGRect</span> f2 = <span style="color:#2e0d6e;">CGRectMake</span>(<span style="color:#1c00cf;">0</span>,<span style="color:#1c00cf;">260</span>-adjustment,<span style="color:#1c00cf;">320</span>,<span style="color:#1c00cf;">160</span>+adjustment);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">myTableView</span>.frame = f2;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">self</span><span style="color:#000000;">.view </span>bringSubviewToFront<span style="color:#000000;">:</span><span style="color:#3f6e74;">myTableView</span><span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#3f6e74;">tile</span> = <span style="color:#aa0d91;">nil</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>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.</div>
<div>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</div>
<div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #643820">#pragma mark tableViewDelegate Methods</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">NSInteger</span>)numberOfSectionsInTableView:(<span style="color:#5c2699;">UITableView</span> *)tableView {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>return<span style="color:#000000;"> </span><span style="color:#1c00cf;">1</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">NSInteger</span>)tableView:(<span style="color:#5c2699;">UITableView</span> *)tableView numberOfRowsInSection:(<span style="color:#5c2699;">NSInteger</span>)section {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span style="white-space:pre"> </span></span>return<span style="color:#000000;"> </span><span style="color:#1c00cf;">5</span><span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">UITableViewCell</span> *)tableView:(<span style="color:#5c2699;">UITableView</span> *)tableView cellForRowAtIndexPath:(<span style="color:#5c2699;">NSIndexPath</span> *)indexPath {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">static</span> <span style="color:#5c2699;">NSString</span> *MyIdentifier = <span style="color:#c41a16;">@&#8221;MyIdentifier&#8221;</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#5c2699;">UITableViewCell</span> *cell = [tableView <span style="color:#2e0d6e;">dequeueReusableCellWithIdentifier</span>:MyIdentifier];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">if</span> (cell == <span style="color:#aa0d91;">nil</span>) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell = [[[</span><span style="color:#5c2699;">UITableViewCell</span><span style="color:#000000;"> </span>alloc<span style="color:#000000;">] </span>initWithFrame<span style="color:#000000;">:</span><span style="color:#5c2699;">CGRectZero</span><span style="color:#000000;"> </span>reuseIdentifier<span style="color:#000000;">:MyIdentifier] </span>autorelease<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span style="white-space:pre"> </span>cell.</span><span style="color:#5c2699;">accessoryType</span><span style="color:#000000;"> = </span>UITableViewCellAccessoryDisclosureIndicator<span style="color:#000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span style="white-space:pre"> </span>[cell </span><span style="color:#2e0d6e;">setText</span><span style="color:#000000;">:</span>@"No Data For Now"<span style="color:#000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="white-space:pre"> </span><span style="color:#aa0d91;">return</span> cell;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span style="white-space:pre"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p>
<div><span style=" ;font-family:Monaco;font-size:10px;"><br />
</span></div>
</div>
<div>You can read data from the source which maintains data according to the last tile tapped.</div>
<div>Let me know if I am missing something.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.webscale.co.in/?feed=rss2&amp;p=244</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>
