<?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>Juggleware Developers&#039; Blog &#187; Programming</title>
	<atom:link href="http://www.juggleware.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.juggleware.com/blog</link>
	<description>news and random thoughts from your friendly neighborhood independent developers at juggleware, llc</description>
	<lastBuildDate>Thu, 15 Jul 2010 20:43:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to get the Return key to dismiss a UITextView</title>
		<link>http://www.juggleware.com/blog/2010/07/how-to-get-the-return-key-to-dismiss-a-uitextview/</link>
		<comments>http://www.juggleware.com/blog/2010/07/how-to-get-the-return-key-to-dismiss-a-uitextview/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 20:05:07 +0000</pubDate>
		<dc:creator>alec</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[UITextView]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=280</guid>
		<description><![CDATA[Need to dismiss they keyboard in a UITextView? Changing the Return key to read &#8220;Done&#8221; doesn&#8217;t make the iPhone keyboard to go away.  Put this code in the delegate for your UITextView and your return key can behave more like &#8230; <a href="http://www.juggleware.com/blog/2010/07/how-to-get-the-return-key-to-dismiss-a-uitextview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Need to dismiss they keyboard in a UITextView? Changing the Return key to read &#8220;Done&#8221; doesn&#8217;t make the iPhone keyboard to go away.  Put this code in the delegate for your UITextView and your return key can behave more like the Done button in the keyboard for a UITextField.</p>
<textarea cols="40" rows="10" name="code" class="Cpp">#pragma mark -
#pragma mark UITextViewDelegate methods

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range 
 replacementText:(NSString *)text{
	if (range.length==0) {
		if ([text isEqualToString:@"\n"]) {
			[textView resignFirstResponder];
			return NO;
		}
	}
	
 return YES;
			 
}</textarea>
	<!-- Wordpress Code Snippet -->
	<script type="text/javascript" src="http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/js/shCore.js"></script><script type="text/javascript" src="http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/js/shBrushCpp.js"></script>
	<link type="text/css" rel="stylesheet" href="http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/css/SyntaxHighlighter.css"/>
	
	<script language="javascript">
	dp.SyntaxHighlighter.ClipboardSwf = 'http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/js/clipboard.swf';
	dp.SyntaxHighlighter.HighlightAll('code');
	</script>
	<!-- End Wordpress Code Snippet -->
	]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/07/how-to-get-the-return-key-to-dismiss-a-uitextview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>plist &gt; JSON &gt; XML</title>
		<link>http://www.juggleware.com/blog/2010/07/plist-json-xml/</link>
		<comments>http://www.juggleware.com/blog/2010/07/plist-json-xml/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 16:14:48 +0000</pubDate>
		<dc:creator>alec</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=266</guid>
		<description><![CDATA[Having developed 4 or 5 iPhone apps now that download remote XML data from servers and populate tables view and other content, I can tell you without reservation that it is the slowest way to go. Performance using JSON is &#8230; <a href="http://www.juggleware.com/blog/2010/07/plist-json-xml/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Having developed 4 or 5 iPhone apps now that download remote XML data from servers and populate tables view and other content, I can tell you without reservation that it is the slowest way to go.</p>
<p>Performance using JSON is quite a bit better, but if you can get access to the server to write a Property List (.plist) file instead of (or alongside) the XML you will be much happier with the ease-of-coding and, more importantly, the speed in which the data loads into your app.</p>
<p>If you use mySQL/PHP for your backend, pretty much everything you need to know is explained in this excellent blog post by Aaron Dunnington:</p>
<p><a href="http://www.dunnington.net/entry/data-driven-iphone-apps-with-property-lists-and-php">Data-driven iPhone Apps with Property Lists and PHP</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/07/plist-json-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Place a UIWebView inside a UIScrollView</title>
		<link>http://www.juggleware.com/blog/2010/07/how-to-place-a-uiwebview-inside-a-uiscrollview/</link>
		<comments>http://www.juggleware.com/blog/2010/07/how-to-place-a-uiwebview-inside-a-uiscrollview/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 16:53:36 +0000</pubDate>
		<dc:creator>alec</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[UIScrollView]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=247</guid>
		<description><![CDATA[To display several pieces of content on a screen, I needed several views. A scroll view (UIScrollView) was necessary to encompass the headline, photo and story text; I had the headline and photo at the top in a fixed area, &#8230; <a href="http://www.juggleware.com/blog/2010/07/how-to-place-a-uiwebview-inside-a-uiscrollview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To display several pieces of content on a screen, I needed several views. A scroll view (<code>UIScrollView</code>) was necessary to encompass the headline, photo and story text; I had the headline and photo at the top in a fixed area, but the content was of variable size as the story length changed.</p>
<p>Originally I had a text view (<code>UITextView</code>) to hold the story, but I wanted to do rich-text formatting, and since my database already used HTML to do italic and bold markup, a web view (<code>UIWebView</code>) was the obvious fit.</p>
<p>However, there are some caveats to using web views, most importantly to do with getting the size of the view after you&#8217;ve set the content. First, you must make sure the content has completed loading before you retrieve the size; you can do this in the delegate handler<code>webViewDidFinishLoading:</code></p>
<p>Secondly, web views don&#8217;t respond correctly to <code>sizeToFit:</code> so you must do some more manual labor using a Javascript call to find the size of the web view after you&#8217;ve inserted the content. Some comments on other web sites mentioned that you can try  <code>[webView sizeThatFits:CGSizeZero]</code> but this did not work for me. </p>
<p>Here&#8217;s the pertinent code from my current project. Also please note that I have a <code>&lt;div id="body"&gt;</code> surrounding my HTML content that I pass into the view. The javascript call uses this to grab the height of the web view after it loads. You&#8217;ll also notice that this calculation sometimes falls a little short so I add 12 points to it. </p>
<p>The code below creates a UIButton beneath the text copy, so I added 70 pixels to the contentSize of the enclosing scroll view. It works perfectly for me; hopefully it helps someone else, too.</p>
<p>If there&#8217;s a more kosher way to do it, I&#8217;d love to hear it. I had considered putting everything (including the headline and photo) inside the UIWebView, but then I would not have been able to have a UIButton beneath/outside it off screen; nor, more importantly would I be able to use my custom NetImageViewer class on the photo. (More on that later.)</p>
<textarea cols="40" rows="10" name="code" class="Cpp">#pragma mark -
#pragma mark UIWebViewDelegate methods 
-(void)webViewDidFinishLoad:(UIWebView *)webView{
	if (webView!=bioWebView)return;

	float h;
	
	NSLog(@"web view is %f high", bioWebView.frame.size.height);
	NSString *heightString = [bioWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"body\").offsetHeight;"];
	NSLog(@"web content is %@ high",heightString);
	
	h = [heightString floatValue] +12.0f; // convert from string to float plus some extra points because calculation is sometimes one line short
	
	bioWebView.frame = CGRectMake(bioWebView.frame.origin.x, bioWebView.frame.origin.y, bioWebView.frame.size.width, h);
	
	// get bottom of text field
	h = bioWebView.frame.origin.y + h + 70; // extra 70 pixels for UIButton at bottom and padding.
	[scrollView setContentSize:CGSizeMake(320, h)];
	
	/* 

        position button code here.... 

        */

}
</textarea>
	<!-- Wordpress Code Snippet -->
	<script type="text/javascript" src="http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/js/shCore.js"></script><script type="text/javascript" src="http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/js/shBrushCpp.js"></script>
	<link type="text/css" rel="stylesheet" href="http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/css/SyntaxHighlighter.css"/>
	
	<script language="javascript">
	dp.SyntaxHighlighter.ClipboardSwf = 'http://www.juggleware.com/blog/wp-content/plugins/wordpress-code-snippet/js/clipboard.swf';
	dp.SyntaxHighlighter.HighlightAll('code');
	</script>
	<!-- End Wordpress Code Snippet -->
	]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/07/how-to-place-a-uiwebview-inside-a-uiscrollview/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Making annotations fit on a Map View.</title>
		<link>http://www.juggleware.com/blog/2010/03/making-annotations-fit-on-a-map-view/</link>
		<comments>http://www.juggleware.com/blog/2010/03/making-annotations-fit-on-a-map-view/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 22:33:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[MKMapView]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=227</guid>
		<description><![CDATA[After struggling with formulae that convert degrees longitude and latitude to meters, I found a much better way to get annotations to fit on a Map View, thanks to this site: http://codisllc.com/blog/zoom-mkmapview-to-fit-annotations/]]></description>
			<content:encoded><![CDATA[<p>After struggling with formulae that convert degrees longitude and latitude to meters, I found a much better way to get annotations to fit on a Map View, thanks to this site:</p>
<p><a href="http://codisllc.com/blog/zoom-mkmapview-to-fit-annotations/">http://codisllc.com/blog/zoom-mkmapview-to-fit-annotations/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/03/making-annotations-fit-on-a-map-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Helpful Core Data debugging</title>
		<link>http://www.juggleware.com/blog/2010/03/helpful-core-data-debugging/</link>
		<comments>http://www.juggleware.com/blog/2010/03/helpful-core-data-debugging/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 05:45:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Core Data]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=225</guid>
		<description><![CDATA[Core Data is really great, but if your app crashes without warning it can be a major headache. Replacing the default error handling code with this more involved approach saved me hours of time debugging: http://www.designcodeexecute.com/2009/08/28/iphone-sdk-coredata-debugging-error-1560-1570]]></description>
			<content:encoded><![CDATA[<p>Core Data is really great, but if your app crashes without warning it can be a major headache. Replacing the default error handling code with this more involved approach saved me hours of time debugging:</p>
<p><a href="http://www.designcodeexecute.com/2009/08/28/iphone-sdk-coredata-debugging-error-1560-1570/"> http://www.designcodeexecute.com/2009/08/28/iphone-sdk-coredata-debugging-error-1560-1570</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/03/helpful-core-data-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can not use an object as parameter to a method (Obj-C errors, part 2)</title>
		<link>http://www.juggleware.com/blog/2010/03/objc-errors-part-2/</link>
		<comments>http://www.juggleware.com/blog/2010/03/objc-errors-part-2/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:13:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Objective C error translation series]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=220</guid>
		<description><![CDATA[This is an easy one to seasoned X-coders, but one that tripped me up a few times when I first got started. BAD CODE: -(void) makePhotoFromImage: (UIImage )image; ERROR: can not use an object as parameter to a method TRANSLATION &#8230; <a href="http://www.juggleware.com/blog/2010/03/objc-errors-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is an easy one to seasoned X-coders, but one that tripped me up a few times when I first got started.</p>
<p>BAD CODE:</p>
<p><code>-(void) makePhotoFromImage: (UIImage )image;</code></p>
<p>ERROR:</p>
<p><code>can not use an object as parameter to a method</code></p>
<p>TRANSLATION</p>
<p>You probably forgot the &#8220;pointer&#8221; asterisk in your declaration. Should be:</p>
<p><code>-(void) makePhotoFromImage: (UIImage *)image;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/03/objc-errors-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective C compiler errors: translations for newbs</title>
		<link>http://www.juggleware.com/blog/2010/03/objective-c-compiler-errors/</link>
		<comments>http://www.juggleware.com/blog/2010/03/objective-c-compiler-errors/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 22:53:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Objective C error translation series]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=212</guid>
		<description><![CDATA[I&#8217;m pretty new at Xcode and Objective C, so there may not be a one-to-one correspondence here between errors and the most probable cause, but this helps me so it may help you. This will be a work in progress; &#8230; <a href="http://www.juggleware.com/blog/2010/03/objective-c-compiler-errors/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pretty new at Xcode and Objective C, so there may not be a one-to-one correspondence here between errors and the most probable cause, but this helps me so it may help you.</p>
<p>This will be a work in progress; I&#8217;ll keep adding as I go.</p>
<p>CODE (from header declarations):<br />
<span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">CreatorHuntView *detailController;</span></p>
<p>ERROR:<br />
<span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">error: expected specifier-qualifier-list before &#8216;CreatorHuntView&#8217;</span></p>
<p>TRANSLATION/PROBABLE CAUSE:<br />
You forgot to import the file in the header file; e.g.<br />
<span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">#import &#8220;CreatorHuntView.h&#8221;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2010/03/objective-c-compiler-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump mySQL database design into OmniGraffle</title>
		<link>http://www.juggleware.com/blog/2009/11/dump-mysql-database-design-into-omnigraffle/</link>
		<comments>http://www.juggleware.com/blog/2009/11/dump-mysql-database-design-into-omnigraffle/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 22:52:30 +0000</pubDate>
		<dc:creator>alec</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/2009/11/dump-mysql-database-design-into-omnigraffle/</guid>
		<description><![CDATA[Check out this blog entry on Designweenie if you are a Mac user that uses OmniGraffle to design mySQL databases. One important note: you will need to run AppleScript Editor in 32-bit mode if you are using Snow Leopard (Mac &#8230; <a href="http://www.juggleware.com/blog/2009/11/dump-mysql-database-design-into-omnigraffle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Check out <a href="http://www.designweenie.com/blog/index.php/1282">this blog entry</a> on Designweenie if you are a Mac user that uses OmniGraffle to design mySQL databases.</p>
<p>One important note: you will need to run AppleScript Editor in 32-bit mode if you are using Snow Leopard (Mac OS X 10.6). Check the 32 bit box in the Get Info box of the application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2009/11/dump-mysql-database-design-into-omnigraffle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL to SQLite cheatsheet for iPhone developers</title>
		<link>http://www.juggleware.com/blog/2009/09/mysql-to-sqlite-cheatsheet-for-iphone-developers/</link>
		<comments>http://www.juggleware.com/blog/2009/09/mysql-to-sqlite-cheatsheet-for-iphone-developers/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:17:26 +0000</pubDate>
		<dc:creator>alec</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.juggleware.com/blog/?p=140</guid>
		<description><![CDATA[Although I started writing this as a cheat-sheet for myself (after many hours of struggling with this by trial-and-error), I figured it would be helpful for other iPhone developers who&#8217;d like to take a mySQL database online and migrate it &#8230; <a href="http://www.juggleware.com/blog/2009/09/mysql-to-sqlite-cheatsheet-for-iphone-developers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Although I started writing this as a cheat-sheet for myself (after many hours of struggling with this by trial-and-error), I figured it would be helpful for other iPhone developers who&#8217;d like to take a mySQL database online and migrate it to their current iPhone project. While other tutorials cover how to read the database into the application from the coding point-of-view, this is just to make sure you get your data uncompromised from your existing mySQL database into a new SQLite DB that your iPhone app can read.</p>
<p>First of all, here&#8217;s what I am currently using; I am including versions in case that&#8217;s relevant to your situation:</p>
<ul>
<li><a href="http://dev.mysql.com/">MySQL</a> 5.0.81</li>
<li>MySQL charset: UTF8-Unicode (utf8)</li>
<li>MySQL connection collation: utf8_unicode_ci</li>
<li><a href="http://www.phpmyadmin.net/home_page/index.php">phpMyAdmin</a> &#8211; 2.11.9.5</li>
<li><a href="http://sqlitebrowser.sourceforge.net/">SQLite Database Browser</a> 1.3 (includes 3.3.5 of the SQLite database engine)</li>
<li>iPhone Dev Kit &#8211; 3.0</li>
<li>XCode 3.1.3</li>
<li>SQLite 3 framework found at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/libsqlite3.dylib</li>
</ul>
<p>You can try other solutions for importing the data into a SQLite format, but I&#8217;ve had the best luck with Mauricio Piacentini&#8217;s SQLite Database Browser. <a href="http://www.sqlite.org/cvstrac/wiki?p=ManagementTools">Other options</a> you might want to try include a <a href="https://addons.mozilla.org/en-US/firefox/addon/5817">Firefox plugin</a>.</p>
<p><strong>Here are the steps, using SQLite Database Browser:</strong></p>
<ol>
<li><a href="http://www.juggleware.com/blog/wp-content/uploads/2009/09/phpAdmin-SQLite_export.png"><img class="size-medium wp-image-143 alignright" title="phpAdmin-SQLite_export" src="http://www.juggleware.com/blog/wp-content/uploads/2009/09/phpAdmin-SQLite_export-300x250.png" alt="phpMyAdmin options for exporting to SQLite" width="300" height="250" /></a>log into phpMyAdmin, select your database and go to <strong>Database&gt; Export</strong>.</li>
<li>On the export tab, make sure all databases are selected, and the <strong>&#8220;SQL&#8221;</strong> radio button is selected.</li>
<li>Select <strong>ANSI</strong> from the pulldown for export compatibility.</li>
<li>Uncheck all options under <strong>Structure</strong> and <strong>Data</strong>, but leave each section checked.</li>
<li><strong>Save as file</strong> should be checked, and probably be via ZIP or GZIP, just in case.</li>
<li>Click the <strong>Go</strong> button to download your file.</li>
<li>Extract the file and open it up in your favorite text editor (I use <a href="http://barebones.com/products/bbedit/">BBEdit</a>).</li>
<li>Find the first <strong>CREATE TABLE</strong> line. We need to modify these by hand to simplify the table creation so that SQLite doesn&#8217;t get confused. For example, my file came down looking like this after the comment section ended:<br />
<code><br />
CREATE TABLE dictionary (<br />
id int(11) NOT NULL auto_increment,<br />
word varchar(100) NOT NULL,<br />
adjective tinyint(1) NOT NULL default '0' COMMENT 'is an adjective',<br />
noun tinyint(1) NOT NULL default '0' COMMENT 'is a noun ',<br />
intro tinyint(1) NOT NULL default '0' COMMENT 'is an intro',<br />
PRIMARY KEY  (id),<br />
UNIQUE KEY words (word)<br />
);<br />
</code></p>
<p>You&#8217;ll want to edit this to remove pretty much everything but the most basic information and normalize the data types to <a href="http://www.sqlite.org/datatype3.html">SQLite 3 Data Types</a>, which are <strong>TEXT, NUMERIC, INTEGER, REAL, or BLOB</strong>.  Your CREATE TABLE should look something like this:</p>
<p><code>CREATE TABLE dictionary(<br />
id  INTEGER PRIMARY KEY ASC,<br />
word TEXT,<br />
adjective  INTEGER,<br />
noun INTEGER,<br />
intro TEXT<br />
);</code></p>
<p>I was using id as a primary key so I&#8217;ve added &#8220;PRIMARY KEY ASC&#8221; after &#8220;id INTEGER&#8221;. (Primary Keys are aliases to row IDs in SQLite, if you have questions read <a href="http://www.sqlite.org/lang_createtable.html#rowid">this</a>.)</p>
<p>However, I&#8217;ve noticed that the SQLite Database browser exports SQL in the even more simplified format with no datatype specification as such, which also seemed to work for me and may work just as well for your needs:</p>
<p><code>CREATE TABLE dictionary (id, word, adjective, noun, intro);<br />
</code></li>
<li>Continue going through your text file and fix all CREATE TABLE lines as in #8, above.</li>
<li>Check your file text encoding. BBEdit may default to Western (Mac OS Roman), which worked for me, but if you have problems you may need to set it to Unicode, depending on your character set.</li>
<li>Check your file for suspicious characters that might cause the import to choke. Single quotation marks used as apostrophes show up as escaped by themselves; for example <code>you're</code> becomes <code>you''re</code>. This seemed to import fine as long as the other guidelines are followed. Here&#8217;s what an example INSERT should look like:
<p><code>INSERT INTO dictionary VALUES(305, 'ne''er-do-well', 0, 1, 0);<br />
</code></li>
<li>Check your line endings. BBEdit defaulted to Unix (LF) which worked for me.</li>
<li>Open up SQLite Database Browser, create a new database (.db) file, and import your SQL text file by selecting <strong>File&gt; Import&gt; Database From SQL File</strong> from the menu.</li>
<li>Check your data by clicking the <strong>Browse Data</strong> tab and make sure everything came in all right. If not, go back over the steps. Look for weird characters, text and line encoding issues, and syntax issues. The only two commands in your file should be CREATE TABLE and INSERT, although technically it should probably begin with <code>BEGIN TRANSACTION;</code> and end with <code>COMMIT;</code></li>
</ol>
<p>Again these steps were derived mostly by trial-and-error, so there may be issues particular to your DB that these guidelines didn&#8217;t solve. Please feel free to add any corrections, tips, and questions to the comments area. </p>
<p>Also, I know that with the iPhone OS 3.0, Core Data can take care of a lot of database functionality for you. I&#8217;d love to hear how people made the transition, and especially how anyone got a pre-existing SQL database into a Core Data store.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.juggleware.com/blog/2009/09/mysql-to-sqlite-cheatsheet-for-iphone-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
