<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Multiple Managed Object Contexts with Core Data</title>
	<atom:link href="http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/</link>
	<description>Cocoa Programming and Other Things</description>
	<lastBuildDate>Mon, 19 Sep 2011 03:07:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Bill</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-10256</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Mon, 17 Jan 2011 01:37:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-10256</guid>
		<description>The Core Recipies sample NSManagedObject subclass contains this helper method for copying entity attributes into another object context. It seems a bit simpler since it leverages NSEntityDescription.

/**
    Copies all of the attribute values from the specified object into the
    current object.  No class comparison is attempted here (to avoid having to
    walk the inheritance tree), so care should be taken to copy values from an
    object with matching keys.
*/

- (void) copyAttributesFromObject: (NSManagedObject *)managedObject {

    // get the array of attribute keys and set the items accordingly
    NSArray *attributeKeys = [[self entity] attributeKeys];
    NSString *attributeName;
    
    // loop through the keys
    int i, count = [attributeKeys count];
    for ( i=0; i&lt;count; i++ ) {
    
        // Get the attribute name, then copy the value
        attributeName = [attributeKeys objectAtIndex: i];
        [self setPrimitiveValue: [managedObject primitiveValueForKey: attributeName] forKey: attributeName];
    }
}</description>
		<content:encoded><![CDATA[<p>The Core Recipies sample NSManagedObject subclass contains this helper method for copying entity attributes into another object context. It seems a bit simpler since it leverages NSEntityDescription.</p>
<p>/**<br />
    Copies all of the attribute values from the specified object into the<br />
    current object.  No class comparison is attempted here (to avoid having to<br />
    walk the inheritance tree), so care should be taken to copy values from an<br />
    object with matching keys.<br />
*/</p>
<p>- (void) copyAttributesFromObject: (NSManagedObject *)managedObject {</p>
<p>    // get the array of attribute keys and set the items accordingly<br />
    NSArray *attributeKeys = [[self entity] attributeKeys];<br />
    NSString *attributeName;</p>
<p>    // loop through the keys<br />
    int i, count = [attributeKeys count];<br />
    for ( i=0; i&lt;count; i++ ) {</p>
<p>        // Get the attribute name, then copy the value<br />
        attributeName = [attributeKeys objectAtIndex: i];<br />
        [self setPrimitiveValue: [managedObject primitiveValueForKey: attributeName] forKey: attributeName];<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-7905</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Mon, 29 Nov 2010 18:24:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-7905</guid>
		<description>Yes, I get this error most often when using a nil managed object context (by accident...). It&#039;s occasionally because I&#039;ve told the persistent store coordinator to use the wrong model file in an app with multiple data models, hence why my next step is to check the list of entities.</description>
		<content:encoded><![CDATA[<p>Yes, I get this error most often when using a nil managed object context (by accident&#8230;). It&#8217;s occasionally because I&#8217;ve told the persistent store coordinator to use the wrong model file in an app with multiple data models, hence why my next step is to check the list of entities.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-7871</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sun, 28 Nov 2010 23:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-7871</guid>
		<description>Thanks, when I looked at logging tempMoc&#039;s managedObjectModel, I realized that my code never initialized tempMoc.  I put an initialization into my getter, and it&#039;s working great now.  Thanks for your help.</description>
		<content:encoded><![CDATA[<p>Thanks, when I looked at logging tempMoc&#8217;s managedObjectModel, I realized that my code never initialized tempMoc.  I put an initialization into my getter, and it&#8217;s working great now.  Thanks for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-7870</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 28 Nov 2010 22:49:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-7870</guid>
		<description>There are various things that can cause this error. In answer to your last question, assuming the entity is named &quot;Part&quot;, that&#039;s what you supply when inserting a new object. Don&#039;t try supplying a managed object model directly, or anything like that.

A few suggestions:

&lt;ul&gt;
	&lt;li&gt;Make sure you&#039;re supplying the name of the entity as specified in the &lt;code&gt;.xcdatamodel&lt;/code&gt; file, not the name of your custom NSManagedObject subclass if you have one.&lt;/li&gt;

	&lt;li&gt;Make sure the managed object context is not &lt;code&gt;nil&lt;/code&gt; by the time this method is called.&lt;/li&gt;

	&lt;li&gt;Log the context&#039;s &lt;code&gt;managedObjectModel&lt;/code&gt; to the console using something like &lt;code&gt;NSLog(@&quot;MOM: %@&quot;, [tempMoc managedObjectModel]);&lt;/code&gt;.&lt;/li&gt;

	&lt;li&gt;Log this managed object model&#039;s list of entities to the console, which will give you a detailed list of the entities it describes, so you can check whether your Part entity is included.&lt;/li&gt;
&lt;/ul&gt;
</description>
		<content:encoded><![CDATA[<p>There are various things that can cause this error. In answer to your last question, assuming the entity is named &#8220;Part&#8221;, that&#8217;s what you supply when inserting a new object. Don&#8217;t try supplying a managed object model directly, or anything like that.</p>
<p>A few suggestions:</p>
<ul>
<li>Make sure you&#8217;re supplying the name of the entity as specified in the <code>.xcdatamodel</code> file, not the name of your custom NSManagedObject subclass if you have one.</li>
<li>Make sure the managed object context is not <code>nil</code> by the time this method is called.</li>
<li>Log the context&#8217;s <code>managedObjectModel</code> to the console using something like <code>NSLog(@"MOM: %@", [tempMoc managedObjectModel]);</code>.</li>
<li>Log this managed object model&#8217;s list of entities to the console, which will give you a detailed list of the entities it describes, so you can check whether your Part entity is included.</li>
</ul>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-7867</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sun, 28 Nov 2010 21:17:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-7867</guid>
		<description>Your pages are brilliant.  I&#039;m currently working on a similar application, with similar code.  One issue I come across is, that when I try to define the instance of my NSManagedObject in my window controller, it gives the error 

&quot;+entityForName: could not locate an NSManagedObjectModel for entity name &#039;Part&#039;&quot; 

in the console, and doesn&#039;t open the window.  I used the following command;

Part *aPart = [NSEntityDescription insertNewObjectForEntityForName:@&quot;Part&quot; inManagedObjectContext:tempMoc];

with Part being the subclass of NSManagedObject.  Do I need to pass the NSManagedObjectModel into my initialization method as an argument?</description>
		<content:encoded><![CDATA[<p>Your pages are brilliant.  I&#8217;m currently working on a similar application, with similar code.  One issue I come across is, that when I try to define the instance of my NSManagedObject in my window controller, it gives the error </p>
<p>&#8220;+entityForName: could not locate an NSManagedObjectModel for entity name &#8216;Part&#8217;&#8221; </p>
<p>in the console, and doesn&#8217;t open the window.  I used the following command;</p>
<p>Part *aPart = [NSEntityDescription insertNewObjectForEntityForName:@"Part" inManagedObjectContext:tempMoc];</p>
<p>with Part being the subclass of NSManagedObject.  Do I need to pass the NSManagedObjectModel into my initialization method as an argument?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vadim Shpakovski</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-1804</link>
		<dc:creator>Vadim Shpakovski</dc:creator>
		<pubDate>Mon, 26 Apr 2010 11:33:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-1804</guid>
		<description>Some techniques for Undo and Window controller management are just brilliant. Thanks for sharing them!</description>
		<content:encoded><![CDATA[<p>Some techniques for Undo and Window controller management are just brilliant. Thanks for sharing them!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Stanley</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-14</link>
		<dc:creator>Martin Stanley</dc:creator>
		<pubDate>Sun, 15 Mar 2009 01:08:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-14</guid>
		<description>I believe that the line:
    • Bind the Value of the relevant text fields to the File’s Owner ’selection’ ‘firstName’ and ‘lastName’ keys.
should read:
    • Bind the Value of the relevant text fields to the New Employee&#039;s ’selection’ ‘firstName’ and ‘lastName’ keys.</description>
		<content:encoded><![CDATA[<p>I believe that the line:<br />
    • Bind the Value of the relevant text fields to the File’s Owner ’selection’ ‘firstName’ and ‘lastName’ keys.<br />
should read:<br />
    • Bind the Value of the relevant text fields to the New Employee&#8217;s ’selection’ ‘firstName’ and ‘lastName’ keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bookmarks about Apps</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-13</link>
		<dc:creator>Bookmarks about Apps</dc:creator>
		<pubDate>Sun, 17 Aug 2008 08:15:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-13</guid>
		<description>[...] - bookmarked by 4 members originally found by be4ugo2 on 2008-07-22  Multiple Managed Object Contexts with Core Data  http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/ - bookmarked [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; bookmarked by 4 members originally found by be4ugo2 on 2008-07-22  Multiple Managed Object Contexts with Core Data  <a href="http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/" rel="nofollow">http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/</a> &#8211; bookmarked [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blog @ Tim Isted &#187; Blog Archive &#187; Sample project code now available for all posts</title>
		<link>http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data/comment-page-1/#comment-12</link>
		<dc:creator>Blog @ Tim Isted &#187; Blog Archive &#187; Sample project code now available for all posts</dc:creator>
		<pubDate>Sun, 20 Jul 2008 17:37:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=10#comment-12</guid>
		<description>[...] the Multiple Managed Object Contexts with Core Data article, the code may be found here: [...]</description>
		<content:encoded><![CDATA[<p>[...] the Multiple Managed Object Contexts with Core Data article, the code may be found here: [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

