Re: Core Data: adding a child data element, saving... 'encodeWithCoder:]: Selector Not Recognized'
Re: Core Data: adding a child data element, saving... 'encodeWithCoder:]: Selector Not Recognized'
- Subject: Re: Core Data: adding a child data element, saving... 'encodeWithCoder:]: Selector Not Recognized'
- From: "Frederick C. Lee" <email@hidden>
- Date: Wed, 5 Apr 2006 15:32:34 -0700
I did as you suggest:
// MapManagedObject.m:
- (void)encodeWithCoder:(NSCoder *)aCoder {
NSLog(@"MapManagedObject.m {encodeWithCoder}"); <-- GDB BREAK
}
- (void)willSave {
[super willSave];
}
=================================================================
(gdb) list
13 return NSApplicationMain(argc, (const char **) arew);
14 }
#0 0x0008fc60 in -[MapManagedObject encodeWithCoder:] at
MapManagedObject.m:98
#1 0x929db584 in -[NSArchiver encodeRootObject:]
#2 0x929db490 in +[NSArchiver archivedDataWithRootObject:]
#3 0x000c0c24 in -[EntityManagedObject saveMemo] at
EntityManagedObject.m:110
#4 0x000c0ce0 in -[EntityManagedObject willSave] at
EntityManagedObject.m:121
#5 0x0008fcf0 in -[MapManagedObject willSave] at MapManagedObject.m:114
It appears to be started at the saveMemo: <-- which is a
NSAttributedString value.
Possible source of problem:
*********
'EntityManagedObject' is the super-superclass of 'MapManagedObject'.
That is, MapManagedObject : RegionManagedObject :
EntityManagedObject : NSManagedObject
********
Apparently there's no data to archive:
(gdb) print (unsigned) [[aCoder archiverData] length]
$1 = 0
=========================================
Okay, now for the solution.
Perhaps I'm TOO DEEP in my design; I should probably FLATTEN
the design:
MapManagedObject : NSManagedObject vs (see above).
Thanks for your suggestion. It got me thinking again.
Ric.
On Apr 5, 2006, at 2:39 PM, Chris Hanson wrote:
On Apr 5, 2006, at 1:34 PM, Frederick C. Lee wrote:
Question: What is Core Data doing?
Why does it have a problem with encodeWithCoder?
Core Data should not be doing anything with -encodeWithCoder:. I
suspect some of your code is trying to encode or otherwise archive
an object that you don't expect.
One strategy for debugging this would be to create a temporary
implementation of -encodeWithCoder: in your MapManagedObject class
that just NSLogs, and then set a breakpoint on that statement in
the debugger. That way you'll be able to look at a stack trace and
see exactly how -encodeWithCoder: is being invoked on the object in
question.
Note that I'm not suggesting that you make your managed object
implement the NSCoding protocol. I'm just suggesting adding a
temporary method so you can get to the bottom of the bogus invocation.
-- Chris
PS - This is a general comment on some discussions I've seen lately
on the Cocoa-Dev list, and I don't mean to single you out
specifically: If you start a thread of discussion on a topic, and
have new information to add to that discussion, it's generally a
good idea to reply to one of the previous posts on the topic with
the new information rather than to start a new thread. That way
the entire thread of discussion will be kept together for people
using threaded mail readers such as Mail.app. This can be really
helpful, for example, in examining things that have already been
tried to resolve an issue.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden