<?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>nothing2fancy &#187; iphone</title>
	<atom:link href="http://nothing2fancy.com/tag/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://nothing2fancy.com</link>
	<description>pew-pew</description>
	<lastBuildDate>Sat, 19 Jun 2010 16:27:39 +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>NSPersistentStoreIncompatibleVersionHashError</title>
		<link>http://nothing2fancy.com/2009/04/02/nspersistentstoreincompatibleversionhasherror/</link>
		<comments>http://nothing2fancy.com/2009/04/02/nspersistentstoreincompatibleversionhasherror/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 05:15:56 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[core data]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://nothing2fancy.com/?p=309</guid>
		<description><![CDATA[Man. This error has been driving me nuts for a few days now. I&#8217;ve got my iPhone app up and running, everything works great until I try and run a

[managedObjectContext save:&#38;error]

Without saving everything works just fine (though it doesn&#8217;t restore data when I restart, obviously). Whenever I try and save, though, I get the following [...]]]></description>
			<content:encoded><![CDATA[<p>Man. This error has been driving me nuts for a few days now. I&#8217;ve got my iPhone app up and running, everything works great until I try and run a</p>

<p><pre>[managedObjectContext save:&amp;error]</pre></p>

<p>Without saving everything works just fine (though it doesn&#8217;t restore data when I restart, obviously). Whenever I try and save, though, I get the following error.</p>

<p><pre>This NSPersistentStoreCoordinator has no persistent stores.  It cannot perform a save operation.</pre></p>

<p>After finally looking in what turned out to be a pretty obvious place, the declaration of the Persistent Store Coordinator in the App Delegate, the default code generated by XCode doesn&#8217;t do any error handling. Here&#8217;s what I replace it with:</p>

<p><pre>if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&amp;error]) {
        if ([error code] == NSPersistentStoreIncompatibleVersionHashError)
            NSLog(@"Persistent Store Incompatible Version error. Please check %@", storeUrl);
        else {
            NSLog([error description]);
        }
    }</pre>
Check it. Turns out that changing your data model after you&#8217;ve already run the code once will render your database inoperable. Of course, there are techniques to upgrade your database to the new model, but at this point I don&#8217;t care. Delete the old database and next time you run the code, everything will move through smoothly, and your new database will be saved.</p>
]]></content:encoded>
			<wfw:commentRss>http://nothing2fancy.com/2009/04/02/nspersistentstoreincompatibleversionhasherror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
