<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>João Prado Maia's Weblog</title>
	<atom:link href="http://pessoal.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://pessoal.org/blog</link>
	<description />
	<lastBuildDate>Tue, 11 Aug 2009 00:42:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Setting up phpUnderControl (and CruiseControl) under debian etch</title>
		<link>http://feedproxy.google.com/~r/joaopmaia/~3/T_TYrcAB_bs/</link>
		<comments>http://pessoal.org/blog/2009/08/10/setting-up-phpundercontrol-and-cruisecontrol-under-debian-etch/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 00:42:33 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cruisecontrol]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[phpundercontrol]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=212</guid>
		<description><![CDATA[This might not be as useful since we finally have debian lenny available, but then again, maybe it will be useful for some people out there.
I had to setup phpUnderControl (and CruiseControl) at my job to manage our day to day work, and it took quite a bit of time to figure out how to [...]]]></description>
			<content:encoded><![CDATA[<p>This might not be as useful since we finally have debian lenny available, but then again, maybe it will be useful for some people out there.</p>
<p>I had to setup phpUnderControl (and CruiseControl) at my job to manage our day to day work, and it took quite a bit of time to figure out how to setup everything properly from the ground up. This post is derived from my notes that we keep in our internal wiki.</p>
<ol>
<li>Edit /etc/apt/sources.list and make sure the unstable repo is listed in there
<pre>
deb http://ftp.debian.org/debian/ unstable non-free
deb-src http://ftp.debian.org/debian/ unstable non-free
</pre>
</li>
<li>apt-get update</li>
<li>apt-get -t unstable install sun-java6-jre sun-java6-jdk</li>
<li>Run &#8220;java -version&#8221; to verify the installation
<pre>
root@etch-64-dev-ui:~# java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)
</pre>
</li>
<li>Add JAVA_HOME to /etc/environment:
<pre>
JAVA_HOME="/usr/lib/jvm/java-6-sun"
</pre>
</li>
<li>source /etc/environment</li>
<li>Download binary distribution of CruiseControl (available here:  http://cruisecontrol.sourceforge.net/download.html)</li>
<li>Install CruiseControl:
<pre>
$ unzip cruisecontrol-bin-2.7.3.zip -d /opt
$ ln -s /opt/cruisecontrol-bin-2.7.3 /opt/cruisecontrol
</pre>
</li>
<li>Install PEAR (if it&#8217;s not already there):
<pre>
$ apt-get install php-pear
</pre>
</li>
<li>Upgrade PEAR to latest release:
<pre>
$ pear upgrade-all
</pre>
</li>
<li>Install PHPUnit and phpUnderControl:
<pre>
$ pear channel-discover pear.phpunit.de
$ pear install phpunit/PHPUnit
$ pear install --force --alldeps phpunit/phpUnderControl
$ phpuc install /opt/cruisecontrol
</pre>
</li>
<li>Install Xdebug (needed for code coverage analysis):
<pre>
$ pear install pecl/xdebug
</pre>
</li>
<li>Add Xdebug zend extension to php.ini (on our case /etc/php5/cli/php.ini):
<pre>
zend_extension="/full/path/to/xdebug.so"
</pre>
</li>
<li>Create a CruiseControl project for your existing PHP project&#8217;s unit tests:
<pre>
$ phpuc project --version-control svn --username "cruisecontrol" --password "password_here" --version-control-url svn://svn.domain.com/repository/project-name/trunk --test-case MyProjectTestSuite --test-dir "/opt/cruisecontrol/projects/my-project/source/unit_tests" --test-file "MyProjectTestSuite.php" --project-name MyProject /opt/cruisecontrol
</pre>
</li>
<li>Edit projects/MyProject/build.xml so it contains the following content:
<pre>
&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;project name="MyProject" default="build" basedir=".">
  &lt;target name="build" depends="php-documentor,php-codesniffer,phpunit"/>
  &lt;target name="php-documentor">
    &lt;exec executable="phpdoc" dir="${basedir}/source" logerror="on">
      &lt;arg line="--title '${ant.project.name}' -i *pear/*,*Smarty/*,*fpdf/*,*jpgraph/* -ue on -t ${basedir}/build/api -d ${basedir}/source/lib -tb '/usr/share/php/data/phpUnderControl/data/phpdoc' -o HTML:Phpuc:phpuc"/>
    &lt;/exec>
  &lt;/target>
  &lt;target name="php-codesniffer">
    &lt;exec executable="phpcs" dir="${basedir}/source" output="${basedir}/build/logs/checkstyle.xml" error="/tmp/checkstyle.error.log">
      &lt;arg line="--ignore=*/PEAR/*,*/Smarty/*,*/fpdf/*,*/jpgraph/*,*/misc/* --report=checkstyle --standard=PEAR ${basedir}/source"/>
    &lt;/exec>
  &lt;/target>
  &lt;target name="phpunit">
    &lt;exec executable="phpunit" dir="${basedir}/source/unit_tests" failonerror="on">
      &lt;arg line=" --log-xml ${basedir}/build/logs/phpunit.xml --log-pmd ${basedir}/build/logs/phpunit.pmd.xml --coverage-xml ${basedir}/build/logs/phpunit.coverage.xml --coverage-html ${basedir}/build/coverage MyProjectTestSuite /opt/cruisecontrol/projects/MyProject/source/unit_tests/MyProjectTestSuite.php"/>
    &lt;/exec>
  &lt;/target>
&lt;/project>
</pre>
</li>
</ol>
<p>You will need to tweak a few things, like the &#8220;MyProject&#8221; name and probably some of the &#8220;ignore rules&#8221; for phpCodeSniffer, but it should be a great starting point for most projects.</p>
<img src="http://feeds.feedburner.com/~r/joaopmaia/~4/T_TYrcAB_bs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2009/08/10/setting-up-phpundercontrol-and-cruisecontrol-under-debian-etch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pessoal.org/blog/2009/08/10/setting-up-phpundercontrol-and-cruisecontrol-under-debian-etch/</feedburner:origLink></item>
		<item>
		<title>Rasmus Lerdorf in Houston!</title>
		<link>http://feedproxy.google.com/~r/joaopmaia/~3/iFnmTdd4mxw/</link>
		<comments>http://pessoal.org/blog/2009/05/29/rasmus-lerdorf-in-houston/#comments</comments>
		<pubDate>Sat, 30 May 2009 04:00:11 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[Houston PHP/MySQL Meetup]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=208</guid>
		<description><![CDATA[Rasmus Lerdorf, creator of the PHP language, will be in Houston in June and graciously volunteered to do a presentation to our group! Sorry about the last minute modification, but we will need to move our meeting from our usual date/time to Wednesday June 10th at 6:00pm. The presentation details below from Rasmus himself:
Architecture, Performance, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lerdorf.com/">Rasmus Lerdorf</a>, creator of the PHP language, will be in Houston in June and graciously volunteered to do a presentation to our group! Sorry about the last minute modification, but we will need to move our meeting from our usual date/time to Wednesday June 10th at 6:00pm. The presentation details below from Rasmus himself:</p>
<blockquote><p>Architecture, Performance, Optimization and Security.</p>
<p>I take a look at the performance of some popular PHP applications and go<br />
through and show the common mistakes people make and show how much of a<br />
difference just a little bit of optimization makes.</p>
<p>Then, if there is still time and interest I&#8217;ll explain the current state<br />
of XSS on the Web with some live examples of XSS issues on some local<br />
sites.  I usually like to have 2-3 hours, but I can squeeze it into less.
</p></blockquote>
<p>I hope to see you all here for this great opportunity! <a href="http://php.meetup.com/121/calendar/10364742/">You can RSVP here.</a></p>
<p>&#8211;Joao</p>
<img src="http://feeds.feedburner.com/~r/joaopmaia/~4/iFnmTdd4mxw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2009/05/29/rasmus-lerdorf-in-houston/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pessoal.org/blog/2009/05/29/rasmus-lerdorf-in-houston/</feedburner:origLink></item>
		<item>
		<title>Customizing the background/border colors of a UITableView (grouped style)</title>
		<link>http://feedproxy.google.com/~r/joaopmaia/~3/8G_EPMYlp14/</link>
		<comments>http://pessoal.org/blog/2009/02/25/customizing-the-background-border-colors-of-a-uitableview/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 02:51:19 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=149</guid>
		<description><![CDATA[Customizing the background color of a UITableView is somewhat easy, but only if you use the plain style. If you use the grouped style of a table view, it starts to get way more complex. There are no easy ways to quickly set a property for the border color and the background color of the [...]]]></description>
			<content:encoded><![CDATA[<p>Customizing the background color of a UITableView is somewhat easy, but only if you use the plain style. If you use the grouped style of a table view, it starts to get way more complex. There are no easy ways to quickly set a property for the border color and the background color of the whole table view cell. Well, there are, but if you try to change some of these values and try to use the grouped style, it will look completely wrong.</p>
<p>Below you have a proper grouped table view using the standard Apple theme:</p>
<p><a href="http://pessoal.org/blog/wp-content/uploads/2009/02/standard.png"><img src="http://pessoal.org/blog/wp-content/uploads/2009/02/standard-200x300.png" alt="Standard style" title="Standard style" width="200" height="300" class="alignleft size-medium wp-image-191" /></a></p>
<p>Looks pretty good, and it is also very simple to build that in objective-c. Assuming you use Interface Builder for your UI work, just set the table view as a &#8220;grouped&#8221;, and then set the title property of each cell, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
    UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
    cell.accessoryType <span style="color: #002200;">=</span> UITableViewCellAccessoryDisclosureIndicator;
&nbsp;
    <span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>list <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;First&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Second&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Third&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
    cell.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>list objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>So now let&#8217;s try something tricky and simply change the backgroundColor property of cell.contentView, as that works fine when dealing with &#8220;plain&#8221; style table views. The code would be just a bit different:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
    UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
    cell.accessoryType <span style="color: #002200;">=</span> UITableViewCellAccessoryDisclosureIndicator;
&nbsp;
    <span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>list <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;First&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Second&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Third&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
    cell.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>list objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;
&nbsp;
    cell.contentView.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor redColor<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>And this is what it looks like:</p>
<p><a href="http://pessoal.org/blog/wp-content/uploads/2009/02/broken.png"><img src="http://pessoal.org/blog/wp-content/uploads/2009/02/broken-200x300.png" alt="Broken results" title="Broken results" width="200" height="300" class="alignleft size-medium wp-image-190" /></a></p>
<p>At first I thought about changing cell.backgroundView, but that doesn&#8217;t work. So you can see that changing the contentView doesn&#8217;t work either, and it actually breaks a bunch of things:</p>
<ul>
<li>No rounded corners on the left side of the table view anymore</li>
<li>The background color on the disclosure image is still set to white</li>
<li>How do we change the border color anyway?</li>
</ul>
<p>So after researching this problem for a while, and asking around for a solution, it seemed like there was no way to customize this stuff without a lot of manual work. Indeed that was the case, but <a href="http://www.michaelakers.net/">Mike Akers</a> (another <a href="http://stackoverflow.com/questions/tagged/iphone">StackOverflow.com</a> member) posted the source code to a solution that he came up with, and that works very well so far. <a href="http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view">You can see his source code here</a> for a custom background view with a border.</p>
<p>Here it is a modified version of my code to use his class:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
    UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
    cell.accessoryType <span style="color: #002200;">=</span> UITableViewCellAccessoryDisclosureIndicator;
&nbsp;
    UILabel <span style="color: #002200;">*</span>label <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UILabel alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
    label.font <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIFont boldSystemFontOfSize<span style="color: #002200;">:</span>16.0f<span style="color: #002200;">&#93;</span>;
    label.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>40.0f, 10.0f, 220.0f, 22.0f<span style="color: #002200;">&#41;</span>;
    label.textColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor whiteColor<span style="color: #002200;">&#93;</span>;
    label.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor clearColor<span style="color: #002200;">&#93;</span>;
    label.opaque <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>list <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;First&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Second&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Third&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
    label.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>list objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>cell.contentView addSubview<span style="color: #002200;">:</span>label<span style="color: #002200;">&#93;</span>;
&nbsp;
    CustomCellBackgroundView <span style="color: #002200;">*</span>bgView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CustomCellBackgroundView alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>indexPath.row <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        bgView.position <span style="color: #002200;">=</span> CustomCellBackgroundViewPositionTop;
    <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>indexPath.row <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        bgView.position <span style="color: #002200;">=</span> CustomCellBackgroundViewPositionMiddle;
    <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
        bgView.position <span style="color: #002200;">=</span> CustomCellBackgroundViewPositionBottom;
    <span style="color: #002200;">&#125;</span>
    cell.backgroundView <span style="color: #002200;">=</span> bgView;
    cell.accessoryView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;more_arrow.png&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>And the resulting interface:</p>
<p><a href="http://pessoal.org/blog/wp-content/uploads/2009/02/proper.png"><img src="http://pessoal.org/blog/wp-content/uploads/2009/02/proper-200x300.png" alt="Proper background and border colors" title="Proper background and border colors" width="200" height="300" class="alignleft size-medium wp-image-198" /></a></p>
<p>Ugly colors, but you get the idea. The code is also way more complex than before, but at least it&#8217;s possible to customize the background and border colors of a table view cell. This is more or less what we use on <a href="http://impleo.net/kneecap.html">Knee Cap</a>, our iPhone app that handles day to day money loans. This is what our custom table view looks like:</p>
<p><a href="http://pessoal.org/blog/wp-content/uploads/2009/02/primary.jpg"><img src="http://pessoal.org/blog/wp-content/uploads/2009/02/primary-208x300.jpg" alt="Knee Cap" title="Knee Cap" width="208" height="300" class="alignleft size-medium wp-image-170" /></a></p>
<img src="http://feeds.feedburner.com/~r/joaopmaia/~4/8G_EPMYlp14" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2009/02/25/customizing-the-background-border-colors-of-a-uitableview/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://pessoal.org/blog/2009/02/25/customizing-the-background-border-colors-of-a-uitableview/</feedburner:origLink></item>
		<item>
		<title>iPhone SDK: Setting up a SQLite database before first use</title>
		<link>http://feedproxy.google.com/~r/joaopmaia/~3/W8n6L79vx0Y/</link>
		<comments>http://pessoal.org/blog/2009/02/24/iphone-sdk-setting-up-a-sqlite-database-before-first-use/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 03:34:53 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=183</guid>
		<description><![CDATA[It&#8217;s quite common to use SQLite databases in iPhone apps to serve as the backend for your product. While there is a way to create the database file dynamically from your objective-c code, it&#8217;s way simpler to create it in your Mac development machine, add it to your Xcode project, and then simply write the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s quite common to use SQLite databases in iPhone apps to serve as the backend for your product. While there is a way to create the database file dynamically from your objective-c code, it&#8217;s way simpler to create it in your Mac development machine, add it to your Xcode project, and then simply write the code to copy the database file from your app bundle to your app&#8217;s document directory.</p>
<p>I use the following code in my projects to do just that:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>copyDBToFinalPath <span style="color: #002200;">&#123;</span>
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>originalDBPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;database_filename_here&quot;</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;db&quot;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
    <span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>paths <span style="color: #002200;">=</span> NSSearchPathForDirectoriesInDomains<span style="color: #002200;">&#40;</span>NSDocumentDirectory, NSUserDomainMask, <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>appSupportDir <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>paths objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>appBundleName <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleName&quot;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>dbNameDir <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@/%@&quot;</span>, appSupportDir, appBundleName<span style="color: #002200;">&#93;</span>;
    <span style="color: #400080;">NSFileManager</span> <span style="color: #002200;">*</span>fileManager <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFileManager</span> defaultManager<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">BOOL</span> isDir <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #a61390;">BOOL</span> dirExists <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>fileManager fileExistsAtPath<span style="color: #002200;">:</span>dbNameDir isDirectory<span style="color: #002200;">:&amp;</span>isDir<span style="color: #002200;">&#93;</span>;
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>dbPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@/database_filename_here.db&quot;</span>, dbNameDir<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>dirExists <span style="color: #002200;">&amp;&amp;</span> isDir<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">BOOL</span> dbExists <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>fileManager fileExistsAtPath<span style="color: #002200;">:</span>dbPath<span style="color: #002200;">&#93;</span>;
        <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>dbExists<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
            <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
            <span style="color: #a61390;">BOOL</span> success <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>fileManager copyItemAtPath<span style="color: #002200;">:</span>originalDBPath toPath<span style="color: #002200;">:</span>dbPath error<span style="color: #002200;">:&amp;</span>error<span style="color: #002200;">&#93;</span>;
            <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>success<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
                NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;error = %@&quot;</span>, error<span style="color: #002200;">&#41;</span>;
            <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
                path <span style="color: #002200;">=</span> dbPath;
            <span style="color: #002200;">&#125;</span>
        <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
            path <span style="color: #002200;">=</span> dbPath;
        <span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>dirExists<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
        <span style="color: #a61390;">BOOL</span> success <span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span>fileManager createDirectoryAtPath<span style="color: #002200;">:</span>dbNameDir attributes<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
        <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>success<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
            NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;failed to create dir&quot;</span><span style="color: #002200;">&#41;</span>;
        <span style="color: #002200;">&#125;</span>
        success <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>fileManager copyItemAtPath<span style="color: #002200;">:</span>originalDBPath toPath<span style="color: #002200;">:</span>dbPath error<span style="color: #002200;">:&amp;</span>error<span style="color: #002200;">&#93;</span>;
        <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>success<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
            NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;error = %@&quot;</span>, error<span style="color: #002200;">&#41;</span>;
        <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
            path <span style="color: #002200;">=</span> dbPath;
        <span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">return</span> path;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>I use that function like so:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>applicationDidFinishLaunching<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIApplication <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>application <span style="color: #002200;">&#123;</span>
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>dbPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self copyDBToFinalPath<span style="color: #002200;">&#93;</span>;
    self.db <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>FMDatabase databaseWithPath<span style="color: #002200;">:</span>dbPath<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span>self.db open<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Could not open database.&quot;</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #002200;">&#125;</span>
    <span style="color: #11740a; font-style: italic;">//[self.db setTraceExecution:YES];</span>
    <span style="color: #11740a; font-style: italic;">//[self.db setLogsErrors:YES];</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// ...</span>
    <span style="color: #11740a; font-style: italic;">// rest of my code here</span>
    <span style="color: #11740a; font-style: italic;">// ...</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>To create that original SQLite database file, just use the standard &#8220;sqlite3&#8243; command found in Mac OS X like so:</p>
<pre>
$ sqlite3 database_filename_here.db
SQLite version 3.4.0
Enter ".help" for instructions
sqlite> .read ./schema.sql
</pre>
<p>The &#8220;schema.sql&#8221; file is where I store my table definitions, and standard inserts.</p>
<img src="http://feeds.feedburner.com/~r/joaopmaia/~4/W8n6L79vx0Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2009/02/24/iphone-sdk-setting-up-a-sqlite-database-before-first-use/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://pessoal.org/blog/2009/02/24/iphone-sdk-setting-up-a-sqlite-database-before-first-use/</feedburner:origLink></item>
		<item>
		<title>My iPhone app is finally live!</title>
		<link>http://feedproxy.google.com/~r/joaopmaia/~3/yluPS7mmDe4/</link>
		<comments>http://pessoal.org/blog/2009/02/16/my-iphone-app-is-finally-live/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 02:50:09 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=168</guid>
		<description><![CDATA[ Knee Cap, the iPhone app I have been working on for the past few weeks, has been approved by Apple and is finally for sale in the App Store.
I&#8217;m looking forward to see the reception it gets after all the hard work I put into it.

]]></description>
			<content:encoded><![CDATA[<p><img src="http://pessoal.org/blog/wp-content/uploads/2009/02/primary-208x300.jpg" alt="primary" title="primary" width="208" height="300" style="float: left; margin-right: 10px;" /> Knee Cap, the iPhone app I have been working on for the past few weeks, has been approved by Apple and is <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=303323584&#038;mt=8">finally for sale in the App Store</a>.</p>
<p>I&#8217;m looking forward to see the reception it gets after all the hard work I put into it.</p>
<div style="clear: both;"></div>
<img src="http://feeds.feedburner.com/~r/joaopmaia/~4/yluPS7mmDe4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2009/02/16/my-iphone-app-is-finally-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pessoal.org/blog/2009/02/16/my-iphone-app-is-finally-live/</feedburner:origLink></item>
	</channel>
</rss>
