Re: awakeFromInsert called twice with nested contexts

2011-11-27 Thread Tom Harrington
On Sat, Nov 19, 2011 at 6:49 PM, Roland King r...@rols.org wrote:

 On Nov 20, 2011, at 5:48 AM, Jerry Krinock wrote:


 On 2011 Nov 16, at 17:16, Tom Harrington wrote:

 I'm finding that if I use nested managed object contexts,
 awakeFromInsert will be called twice on new objects.

 I'm wondering if this is a Core Data bug or a documentation bug.

 I'd say it's a pretty serious Core Data bug.  I've not had an occasion to 
 use nested managed object contexts yet, but I put things in -awakeFromInsert 
 that I only want to happen once.


 It's certainly not explicitly documented, however a quick scan of the iOS 
 forums finds another 3 developers who've discovered the same thing. Is it 
 really the same object however? It can't be, right, they have different 
 addresses, so Core Data is arguably doing what the documentation says, it's 
 calling awakeFromInsert only once in the object's lifetime, you just have two 
 objects, one in each context.

Actually I don't, so far as I can tell. As I mentioned in my previous
message, I get the same managed object ID both times. I haven't
checked the address, but surely if they were different objects they
wouldn't have the same ID.

 What does the object look like when you get the second call? Has Core Data 
 literally just created it in the second MOC and is calling awakeFromInsert on 
 it before (I assume) populating the data on it from the original, or is it 
 already a clone of the first, with properties and relationships set on it? If 
 the former that seems not too inconsistent, new object in new store gets 
 called to set up defaults before the properties you set on it are cloned 
 over, if the second case, that's much harder to deal with (and sounds like a 
 bug)

The object appears the same both times-- a new object with no
properties or relationships set.

-- 
Tom Harrington
atomicb...@gmail.com
AIM: atomicbird1
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-27 Thread Tom Harrington
On Sun, Nov 20, 2011 at 2:34 PM, Richard Somers
rsomers.li...@infowest.com wrote:
 On Nov 16, 2011, at 6:16 PM, Tom Harrington wrote:

 I'm finding that if I use nested managed object contexts,
 awakeFromInsert will be called twice on new objects.


 On Mac OS X 10.7 NSManagedObjectContext can have a parentContext.

 Perhaps this would be applicable.

That is specifically what I meant when I mentioned nested contexts--
one context whose parent context is another context.

-- 
Tom Harrington
atomicb...@gmail.com
AIM: atomicbird1
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-27 Thread Tom Harrington
On Sun, Nov 27, 2011 at 6:09 PM, Quincey Morris
quinceymor...@rivergatesoftware.com wrote:
 On Nov 27, 2011, at 16:49 , Tom Harrington wrote:

 Actually I don't, so far as I can tell. As I mentioned in my previous
 message, I get the same managed object ID both times. I haven't
 checked the address, but surely if they were different objects they
 wouldn't have the same ID.


 You're wrong about that. Different objects will of course have different
 pointers, but that's the most you can say.

 The object, and hence the object pointer, is specific to a managed object
 context. The object ID is an attribute of the persistent store, and is
 independent of the MOC.

If they're different objects then I'm getting duplicates, which is at
least as much of a bug and possibly more so. What I observe is that if
I add 10 objects, I get 20 calls to awakeFromInsert, 10 for the child
context and 10 for the parent. But, there are only 10 unique managed
object IDs. It might be that I just happen to be getting the same IDs
for two completely different sets of objects, but there shouldn't be
two sets in the first place.

-- 
Tom Harrington
atomicb...@gmail.com
AIM: atomicbird1
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-27 Thread Quincey Morris
On Nov 27, 2011, at 20:50 , Tom Harrington wrote:

 If they're different objects then I'm getting duplicates, which is at
 least as much of a bug and possibly more so. What I observe is that if
 I add 10 objects, I get 20 calls to awakeFromInsert, 10 for the child
 context and 10 for the parent. But, there are only 10 unique managed
 object IDs. It might be that I just happen to be getting the same IDs
 for two completely different sets of objects, but there shouldn't be
 two sets in the first place.

Objects are specific to a managed object context, so it's correct that there 
would be 20 objects, and it's correct that there would be only 10 object IDs.

For any given row in the persistent store, there will be one object *per 
managed context* in memory. The set of objects that correspond to the row all 
have the same object ID -- that's what object IDs are for. All of the numbers 
you're quoting are consistent:

1 persistent store
2 managed object contexts
10 rows to be inserted in the persistent store (when the MOCs are 
eventually saved)
10 object IDs, one per row
20 object instances, one per row per managed object 
context___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-27 Thread Kyle Sluder
On Nov 27, 2011, at 9:23 PM, Quincey Morris 
quinceymor...@rivergatesoftware.com wrote:

 On Nov 27, 2011, at 20:50 , Tom Harrington wrote:
 
 If they're different objects then I'm getting duplicates, which is at
 least as much of a bug and possibly more so. What I observe is that if
 I add 10 objects, I get 20 calls to awakeFromInsert, 10 for the child
 context and 10 for the parent. But, there are only 10 unique managed
 object IDs. It might be that I just happen to be getting the same IDs
 for two completely different sets of objects, but there shouldn't be
 two sets in the first place.
 
 Objects are specific to a managed object context, so it's correct that there 
 would be 20 objects, and it's correct that there would be only 10 object IDs.

To clarify: if you had two nested MOCs that shared the same parent MOC, how 
would you plan on editing an object in Nested Context A as well as in Nested 
Context B if there *weren't* two separate NSManagedObject instances with the 
same object ID, each associated with a different context?

--Kyle Sluder___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-20 Thread Richard Somers
On Nov 16, 2011, at 6:16 PM, Tom Harrington wrote:

 I'm finding that if I use nested managed object contexts,
 awakeFromInsert will be called twice on new objects.


On Mac OS X 10.7 NSManagedObjectContext can have a parentContext.

Perhaps this would be applicable.

--Richard

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-19 Thread Jerry Krinock

On 2011 Nov 16, at 17:16, Tom Harrington wrote:

 I'm finding that if I use nested managed object contexts,
 awakeFromInsert will be called twice on new objects.

 I'm wondering if this is a Core Data bug or a documentation bug.

I'd say it's a pretty serious Core Data bug.  I've not had an occasion to use 
nested managed object contexts yet, but I put things in -awakeFromInsert that I 
only want to happen once.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: awakeFromInsert called twice with nested contexts

2011-11-19 Thread Roland King

On Nov 20, 2011, at 5:48 AM, Jerry Krinock wrote:

 
 On 2011 Nov 16, at 17:16, Tom Harrington wrote:
 
 I'm finding that if I use nested managed object contexts,
 awakeFromInsert will be called twice on new objects.
 
 I'm wondering if this is a Core Data bug or a documentation bug.
 
 I'd say it's a pretty serious Core Data bug.  I've not had an occasion to use 
 nested managed object contexts yet, but I put things in -awakeFromInsert that 
 I only want to happen once.
 

It's certainly not explicitly documented, however a quick scan of the iOS 
forums finds another 3 developers who've discovered the same thing. Is it 
really the same object however? It can't be, right, they have different 
addresses, so Core Data is arguably doing what the documentation says, it's 
calling awakeFromInsert only once in the object's lifetime, you just have two 
objects, one in each context. 

What does the object look like when you get the second call? Has Core Data 
literally just created it in the second MOC and is calling awakeFromInsert on 
it before (I assume) populating the data on it from the original, or is it 
already a clone of the first, with properties and relationships set on it? If 
the former that seems not too inconsistent, new object in new store gets called 
to set up defaults before the properties you set on it are cloned over, if the 
second case, that's much harder to deal with (and sounds like a bug)



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com