<?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>Rahul Vaidya's Blog &#187; xcode</title>
	<atom:link href="http://www.rvaidya.com/blog/tag/xcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rvaidya.com/blog</link>
	<description>Development, Tech, Whatever.</description>
	<lastBuildDate>Wed, 16 Sep 2009 00:33:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Wrapper classes for using SQLite on iPhone/Cocoa</title>
		<link>http://www.rvaidya.com/blog/iphone/2009/02/14/wrapper-classes-for-using-sqlite-on-iphonecocoa/</link>
		<comments>http://www.rvaidya.com/blog/iphone/2009/02/14/wrapper-classes-for-using-sqlite-on-iphonecocoa/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 00:28:47 +0000</pubDate>
		<dc:creator>Rahul</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.rvaidya.com/blog/?p=19</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Information on using SQLite for local storage on Cocoa isn&#8217;t all that easy to find.  The best resource, as always, is Google, and you can find a few tutorials with step by step instructions and code samples on how to use it.  Well, here&#8217;s another basic step by step set of instructions, but rather than including code samples, I have written a couple of wrapper classes for creating databases, making queries, and getting results.</p>
<p>Steps:</p>
<p>1: Include the SQLite framework in your project.  It&#8217;s usually located somewhere like &#8220;/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/lib/libsqlite3.0.dylib&#8221; (why is developer in there twice?)</p>
<p>2: Create a base sqlite database file, and modify SQLite.m so that the filename method refers to it.  Place it in your main resource path.  This will be copied out of your bundle into your application&#8217;s Documents directory.  If you need help on creating one of these and managing it, there is a fantastic <a href="https://addons.mozilla.org/en-US/firefox/addon/5817" target="_blank">FireFox extension</a> that does it for you!</p>
<p>3: Add the source files to your project.</p>
<p>Usage can be as simple as:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Objective-C"><div class="devcodeoverflow"><ol><li></li><li>SQLiteResult <span style="color: #002200;">*</span>result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SQLite query<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SELECT * from test;&quot;</span><span style="color: #002200;">&#93;</span>;</li><li><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>row <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>result.rows objectAtIndex<span style="color: #002200;">:</span>0<span style="color: #002200;">&#93;</span>;</li><li><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>firstValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>row objectAtIndex<span style="color: #002200;">:</span>0<span style="color: #002200;">&#93;</span>;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>NSArray columnNames contains NSStrings of all the names.<br />
NSArray columnTypes contains NSStrings of all the types.<br />
NSArray rows contains NSArrays, where each of these contains NSStrings of all the row values in that row.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rvaidya.com/blog/iphone/2009/02/14/wrapper-classes-for-using-sqlite-on-iphonecocoa/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
