Validation error in a relationship? (in coredata)

  • hello guys. I'm making a Core Data model. This model uses custom
    NSManagedObject with some various methods. An entity have a
    relationship 1:1 with the other. To set the releationship I've made
    entity a setValue: entity_b forKey: mykey.

    However when I save to the store I receive an error: mykey value
    (entity b) is not valid (in entity A relationship destinatin is entity
    b).
    Why?

    NSError "draft_content is not valid." Domain=NSCocoaErrorDomain
    Code=1550 UserInfo={
        NSLocalizedDescription = "draft_content is not valid.";
        NSValidationErrorKey = "draft_content";
        NSValidationErrorObject = <ANTStArticle: 0xd17dcc0> (entity:
    DRAFT; id: 0xd1d8480
    <x-coredata:///DRAFT/t36C100E1-1164-4967-AEE1-9BD60BFFDB73> ; data: {
        "draft_connection" = 0;
        "draft_content" = (0xd1e53e0
    <x-coredata:///DRAFT_CONTENT/tC49CCDF8-28BF-42CB-A203-907129F9AA16>);
        "draft_isSentArticle" = 0;
        "draft_isSuspended" = 0;
        "draft_locked" = 0;
        "draft_markAndSendNextTime" = nil;
        "draft_messageID" = "<nemoSun101407111826...>";
        "draft_newsgroups" = nil;
        "draft_profile" = 0;
        "draft_replyToID" = nil;
        "draft_sendLaterTime" = nil;
        "draft_sentDate" = nil;
        "draft_signName" = -1;
    });
        NSValidationErrorValue = <_NSFaultingMutableSet: 0xd1dc630>
    (<ANTStArticle_Content: 0xd1dce20> (entity: DRAFT_CONTENT; id:
    0xd1e53e0 <x-coredata:///DRAFT_CONTENT/tC49CCDF8-28BF-42CB-A203-907129F9AA16>
    ; data: {
        "body_text" = kkkjkj;
        "headers_data" = <040b7374 7265616d 74797065 6481e803 84014084
    8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    }));
    }
  • hello guys. I'm making a Core Data model. This model uses custom
    NSManagedObject with some various methods. An entity have a
    relationship 1:1 with the other. To set the releationship I've made
    entity a setValue: entity_b forKey: mykey.

    However when I save to the store I receive an error: mykey value
    (entity b) is not valid (in entity A relationship destinatin is entity
    b).
    Why?

    NSError "draft_content is not valid." Domain=NSCocoaErrorDomain
    Code=1550 UserInfo={
      NSLocalizedDescription = "draft_content is not valid.";
      NSValidationErrorKey = "draft_content";
      NSValidationErrorObject = <ANTStArticle: 0xd17dcc0> (entity:
    DRAFT; id: 0xd1d8480
    <x-coredata:///DRAFT/t36C100E1-1164-4967-AEE1-9BD60BFFDB73> ; data: {
      "draft_connection" = 0;
      "draft_content" = (0xd1e53e0
    <x-coredata:///DRAFT_CONTENT/tC49CCDF8-28BF-42CB-A203-907129F9AA16>);
      "draft_isSentArticle" = 0;
      "draft_isSuspended" = 0;
      "draft_locked" = 0;
      "draft_markAndSendNextTime" = nil;
      "draft_messageID" = "<nemoSun101407111826...>";
      "draft_newsgroups" = nil;
      "draft_profile" = 0;
      "draft_replyToID" = nil;
      "draft_sendLaterTime" = nil;
      "draft_sentDate" = nil;
      "draft_signName" = -1;
    });
      NSValidationErrorValue = <_NSFaultingMutableSet: 0xd1dc630>
    (<ANTStArticle_Content: 0xd1dce20> (entity: DRAFT_CONTENT; id:
    0xd1e53e0 <x-coredata:///DRAFT_CONTENT/tC49CCDF8-28BF-42CB-A203-907129F9AA16>
    ; data: {
      "body_text" = kkkjkj;
      "headers_data" = <040b7374 7265616d 74797065 6481e803 84014084
    8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    }));
    }
  • On Oct 14, 2007, at 2:37 AM, dexter.cocoa dexter wrote:

    > hello guys. I'm making a Core Data model. This model uses custom
    > NSManagedObject with some various methods. An entity have a
    > relationship 1:1 with the other. To set the releationship I've made
    > entity a setValue: entity_b forKey: mykey.
    >
    > However when I save to the store I receive an error: mykey value
    > (entity b) is not valid (in entity A relationship destinatin is entity
    > b).
    > Why?

    You need to not just post the error, but post a better description of
    your model and a bit of the code that uses that model and fails.

    A few things I've noticed from the error:

    (1) You're not adhering to Cocoa coding conventions; your entities
    have all-caps (rather than inter-caps) names, and your properties use
    underbars rather than internal capitals.  Core Data is not a SQL
    database, it's part of Cocoa; rather than following (some platforms')
    SQL naming conventions, you should follow Cocoa naming conventions.

    (2) The error that comes back is a generic validation error (1550, see
    <CoreData/CoreDataErrors.h>) indicating that the object on the other
    end of the draft_content relationship is invalid in some way.  That
    doesn't necessarily mean that the content of the relationship is an
    instance of the wrong entity (though we couldn't tell that without
    seeing your model); it could be some other validation error.  Do you
    have any custom validation code on your entity classes?

    (3) The error value contains a set that contains the object.  Is it
    perhaps the case that you tried to manipulate a to-one relationship as
    if it were a to-many relationship, or the opposite (manipulate a to-
    many relationship as a to-one)?

    Beyond that, I can't really think of anything.  Please share more
    information about your problem to help us help you better.  Thanks!

      -- Chris
  • From looking at the error's NSValidationErrorValue, it looks like
    you're passing a set (specifically a Core Data relationship set) as
    the value instead of an entityB instance.

    If the relationship was really modeled as a 1:1 relationship, then you
    need to do
    [instanceOfA setValue:instanceOfB forKey:theKey]

    Check that wherever you're coming up with instanceB that you're not
    really getting an NSSet.

    On Oct 14, 2007, at 12:02 PM, <cocoa-dev-request...> wrote:

    > Message: 8
    > Date: Sun, 14 Oct 2007 11:19:54 +0200
    > From: "Hell's KItchen Hell's KItchen" <thehellskitchen...>
    > Subject: Validation error in a relationship? (in coredata)
    > To: <cocoa-dev...>
    > Message-ID:
    > <e2449c300710140219g194d2f43m1d54dd1874e4e16a...>
    > Content-Type: text/plain; charset=ISO-8859-1
    >
    > hello guys. I'm making a Core Data model. This model uses custom
    > NSManagedObject with some various methods. An entity have a
    > relationship 1:1 with the other. To set the releationship I've made
    > entity a setValue: entity_b forKey: mykey.
    >
    > However when I save to the store I receive an error: mykey value
    > (entity b) is not valid (in entity A relationship destinatin is entity
    > b).
    > Why?
    >
    > NSError "draft_content is not valid." Domain=NSCocoaErrorDomain
    > Code=1550 UserInfo={
    > NSLocalizedDescription = "draft_content is not valid.";
    > NSValidationErrorKey = "draft_content";
    > NSValidationErrorObject = <ANTStArticle: 0xd17dcc0> (entity:
    > DRAFT; id: 0xd1d8480
    > <x-coredata:///DRAFT/t36C100E1-1164-4967-AEE1-9BD60BFFDB73> ; data: {
    > "draft_connection" = 0;
    > "draft_content" = (0xd1e53e0
    > <x-coredata:///DRAFT_CONTENT/tC49CCDF8-28BF-42CB-A203-907129F9AA16>);
    > "draft_isSentArticle" = 0;
    > "draft_isSuspended" = 0;
    > "draft_locked" = 0;
    > "draft_markAndSendNextTime" = nil;
    > "draft_messageID" = "<nemoSun101407111826...>";
    > "draft_newsgroups" = nil;
    > "draft_profile" = 0;
    > "draft_replyToID" = nil;
    > "draft_sendLaterTime" = nil;
    > "draft_sentDate" = nil;
    > "draft_signName" = -1;
    > });
    > NSValidationErrorValue = <_NSFaultingMutableSet: 0xd1dc630>
    > (<ANTStArticle_Content: 0xd1dce20> (entity: DRAFT_CONTENT; id:
    > 0xd1e53e0 <x-coredata:///DRAFT_CONTENT/tC49CCDF8-28BF-42CB-A203-907129F9AA16
    >>
    > ; data: {
    > "body_text" = kkkjkj;
    > "headers_data" = <040b7374 7265616d 74797065 6481e803 84014084
    > 8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    > }));
    > }
    >
  • Oh damn, I've tried to make a 1:n relationship to solve the previous
    described problem. However I've a similar error with the 1:1 rel.
    You can see it below, while this is my schema
    (http://img100.imageshack.us/img100/5711/immagine1gr2.png) and this
    the code for two used subclasses of nsmanagedobject if it can be
    usefull... but it's a normal class (ANTStArticle:
    http://paste.lisp.org/display/49214 - ANTStArticle_Content:
    http://paste.lisp.org/display/49215)

    -------METHOD
    - (ANTStArticle_Content *) _getContentArchive {
    ANTStArticle_Content *archive = [self valueForKeyPath:STARTICLE_KEY_ARCHIVE];

    if (archive == nil) {
      archive = [[ANTStArticle_Content alloc] initWithEntity: [self
    _getEntityFromBundle: @"DRAFT_CONTENT"]
        insertIntoManagedObjectContext:[[NGSharedDrafts sharedDrafts]
    managedObjectContext]];

      [self setValue: archive forKey: STARTICLE_KEY_ARCHIVE];
    }
    return archive;
    }

    --------ERROR
    NSError "draft_content is not valid." Domain=NSCocoaErrorDomain
    Code=1550 UserInfo={
        NSLocalizedDescription = "draft_content is not valid.";
        NSValidationErrorKey = "draft_content";
        NSValidationErrorObject = <ANTStArticle: 0xbc25f0> (entity: DRAFT;
    id: 0xe1da250 <x-coredata:///DRAFT/t36F12C85-17FC-4C1E-BC84-D0D3490AD65A>
    ; data: {
        "draft_connection" = 0;
        "draft_content" = 0xe1e6d20
    <x-coredata:///DRAFT_CONTENT/t41A06899-D700-46E6-ABEE-6214CCB16700>;
        "draft_isSentArticle" = 0;
        "draft_isSuspended" = 0;
        "draft_locked" = 0;
        "draft_markAndSendNextTime" = nil;
        "draft_messageID" = "<nemoMon101507100432...>";
        "draft_newsgroups" = nil;
        "draft_profile" = 0;
        "draft_replyToID" = nil;
        "draft_sendLaterTime" = nil;
        "draft_sentDate" = nil;
        "draft_signName" = -1;
    });
        NSValidationErrorValue = <ANTStArticle_Content: 0xe1de780>
    (entity: DRAFT_CONTENT; id: 0xe1e6d20
    <x-coredata:///DRAFT_CONTENT/t41A06899-D700-46E6-ABEE-6214CCB16700> ;
    data: {
        "body_text" = fddfdf;
        "headers_data" = <040b7374 7265616d 74797065 6481e803 84014084
    8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    });
    }
  • On Oct 15, 2007, at 1:13 PM, dexter.cocoa dexter wrote:

    > Oh damn, I've tried to make a 1:n relationship to solve the previous
    > described problem. However I've a similar error with the 1:1 rel.
    > You can see it below, while this is my schema
    > (http://img100.imageshack.us/img100/5711/immagine1gr2.png) and this
    > the code for two used subclasses of nsmanagedobject if it can be
    > usefull... but it's a normal class (ANTStArticle:
    > http://paste.lisp.org/display/49214 - ANTStArticle_Content:
    > http://paste.lisp.org/display/49215)
    >
    > -------METHOD
    > - (ANTStArticle_Content *) _getContentArchive {
    > ANTStArticle_Content *archive = [self
    > valueForKeyPath:STARTICLE_KEY_ARCHIVE];
    >
    > if (archive == nil) {
    > archive = [[ANTStArticle_Content alloc] initWithEntity: [self
    > _getEntityFromBundle: @"DRAFT_CONTENT"]
    > insertIntoManagedObjectContext:[[NGSharedDrafts sharedDrafts]
    > managedObjectContext]];
    >
    > [self setValue: archive forKey: STARTICLE_KEY_ARCHIVE];
    > }
    > return archive;
    > }
    >
    >
    > --------ERROR
    > NSError "draft_content is not valid." Domain=NSCocoaErrorDomain
    > Code=1550 UserInfo={
    > NSLocalizedDescription = "draft_content is not valid.";
    > NSValidationErrorKey = "draft_content";
    > NSValidationErrorObject = <ANTStArticle: 0xbc25f0> (entity: DRAFT;
    > id: 0xe1da250 <x-coredata:///DRAFT/t36F12C85-17FC-4C1E-BC84-D0D3490AD65A
    >>
    > ; data: {
    > "draft_connection" = 0;
    > "draft_content" = 0xe1e6d20
    > <x-coredata:///DRAFT_CONTENT/t41A06899-D700-46E6-ABEE-6214CCB16700>;
    > "draft_isSentArticle" = 0;
    > "draft_isSuspended" = 0;
    > "draft_locked" = 0;
    > "draft_markAndSendNextTime" = nil;
    > "draft_messageID" = "<nemoMon101507100432...>";
    > "draft_newsgroups" = nil;
    > "draft_profile" = 0;
    > "draft_replyToID" = nil;
    > "draft_sendLaterTime" = nil;
    > "draft_sentDate" = nil;
    > "draft_signName" = -1;
    > });
    > NSValidationErrorValue = <ANTStArticle_Content: 0xe1de780>
    > (entity: DRAFT_CONTENT; id: 0xe1e6d20
    > <x-coredata:///DRAFT_CONTENT/t41A06899-D700-46E6-ABEE-6214CCB16700> ;
    > data: {
    > "body_text" = fddfdf;
    > "headers_data" = <040b7374 7265616d 74797065 6481e803 84014084
    > 8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    > });
    > }

    Ok, this looks better. Still not sure what the problem might be. The
    two things I'd check:

    1) Does the source object have a validateDraft_Content:… method
    returning NO?

    2) Are both the source and destination objects in the same context?

    Short of one of those two cases, I'd need to see the whole bt to
    diagnose this.
    Thanks

    -----------------------------
    Ronzilla
    Core Bindings/Cocoa Builder/Interface Data
  • On Oct 15, 2007, at 1:13 PM, dexter.cocoa dexter wrote:

    > Oh damn, I've tried to make a 1:n relationship to solve the previous
    > described problem. However I've a similar error with the 1:1 rel.
    > You can see it below, while this is my schema
    > (http://img100.imageshack.us/img100/5711/immagine1gr2.png) and this
    > the code for two used subclasses of nsmanagedobject if it can be
    > usefull... but it's a normal class (ANTStArticle:
    > http://paste.lisp.org/display/49214 - ANTStArticle_Content:
    > http://paste.lisp.org/display/49215)

    Hell's Kitchen/Dexter/Malcolm:

    I suspect the instances of both the DRAFT entity and the DRAFT_CONTENT
    entity are in some sort of very invalid state.  In your code pastes,
    you appear to have substantially incorrect Core Data accessor methods.

    For example, you have methods that look like this (paraphrased to
    resolve some #define constants):

    - (void)setMessageBody:(NSString *)body {
        [self setPrimitiveValue:body forKey:@"body_text"];
    }

    - (NSString *)getBody {
        return [self primitiveValueForKey:@"body_text"];
    }

    I doubt this is ever going to do what you want.  (Plus it's
    inconsistent with Cocoa naming conventions and with itself.)  If
    you're going to write accessors for your modeled properties, you need
    to write them according to how the Core Data documentation specifies
    your accessors need to be written; you also need to follow the
    appropriate naming conventions for both the properties and the methods
    so that all appropriate methods will be invoked at the appropriate
    times.

    In particular, subclasses of NSManagedObject *do not* enable automatic
    notification of observers by default, unlike other subclasses of
    NSObject.  Thus you always need to include these in the
    implementations of your accessor methods.

    In this case, I would rename your attribute from "body_text" to
    "messageBody" and write the accessor methods like this:

    - (void)setMessageBody:(NSString *)value {
        NSString *temp = [value copy];
        [self willChangeValueForKey:@"messageBody"];
        [self setPrimitiveValue:temp forKey:@"messageBody"];
        [self didChangeValueForKey:@"messageBody"];
        [temp release];
    }

    - (NSString *)messageBody {
        NSString *value;
        [self willAccessValueForKey:@"messageBody"];
        value = [self primitiveValueForKey:@"messageBody"];
        [self didAccessValueForKey:@"messageBody"];
        return value;
    }

    The -{will,did}{Change,Access}ValueForKey: invocations are critical to
    ensuring correctness within your application.

      -- Chris

    PS - It would be helpful to stick to one identity when asking
    questions on cocoa-dev, as it can help "fill in" context between
    questions.  Which isn't to say each question shouldn't also stand on
    its own.  Both are important when participating in a technical
    community.
  • > Hell's Kitchen/Dexter/Malcolm:

    Hello Chris, I'm sorry but I've encountered some problems with my
    gmail account and apple ml so I've created another accounts.

    Well, regarding the problem I've created right (?) custom accessor
    methods but the problem persist. This is the code:
    ANTStArticle.m -> http://pastebin.com/m65f42c4b
    ANTStArticle_Content.m -> http://pastebin.com/m57644dd9
    While you can download the entire project here:
    http://www.mediafire.com/?5iyukzukm20

    The problem still to be this:
    NSError "draftContent is not valid." Domain=NSCocoaErrorDomain
    Code=1550 UserInfo={
        NSLocalizedDescription = "draftContent is not valid.";
        NSValidationErrorKey = draftContent;
        NSValidationErrorObject = <ANTStArticle: 0x3244d0> (entity: DRAFT;
    id: 0x336850 <x-coredata:///DRAFT/tCA7B7E93-3242-40D2-B324-6D3FF369E009>
    ; data: {
        draftConnection = -1;
        draftContent = 0x33b0e0
    <x-coredata:///DRAFT_CONTENT/tA2EE9788-F757-4A55-BF5D-7DC7122FBB9D>;
        draftIsSentArticle = 0;
        draftIsSuspended = 0;
        draftLocked = 0;
        draftMarkAndSendNextTime = 0;
        draftMessageID = uid;
        draftNewsgroups = nil;
        draftProfile = -1;
        draftReplyToID = nil;
        draftSendLaterTime = nil;
        draftSentDate = nil;
        draftSignName = -1;
    });
        NSValidationErrorValue = <ANTStArticle_Content: 0x3314c0> (entity:
    DRAFT_CONTENT; id: 0x33b0e0
    <x-coredata:///DRAFT_CONTENT/tA2EE9788-F757-4A55-BF5D-7DC7122FBB9D> ;
    data: {
        messageBody = "";
        messageHeaders = <040b7374 7265616d 74797065 6481e803 84014084
    8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    });
    }
  • ops.
    Fixed a problem with custom accessor mehtod in ANTStArticle_Content.
    Should be ok now (http://pastebin.com/m38aa3280).
    But the problem persist.
    Umpf where f* is the error? :((

    On 10/16/07, malcom <malcom.mac...> wrote:
    >> Hell's Kitchen/Dexter/Malcolm:
    >
    > Hello Chris, I'm sorry but I've encountered some problems with my
    > gmail account and apple ml so I've created another accounts.
    >
    > Well, regarding the problem I've created right (?) custom accessor
    > methods but the problem persist. This is the code:
    > ANTStArticle.m -> http://pastebin.com/m65f42c4b
    > ANTStArticle_Content.m -> http://pastebin.com/m57644dd9
    > While you can download the entire project here:
    > http://www.mediafire.com/?5iyukzukm20
    >
    > The problem still to be this:
    > NSError "draftContent is not valid." Domain=NSCocoaErrorDomain
    > Code=1550 UserInfo={
    > NSLocalizedDescription = "draftContent is not valid.";
    > NSValidationErrorKey = draftContent;
    > NSValidationErrorObject = <ANTStArticle: 0x3244d0> (entity: DRAFT;
    > id: 0x336850 <x-coredata:///DRAFT/tCA7B7E93-3242-40D2-B324-6D3FF369E009>
    > ; data: {
    > draftConnection = -1;
    > draftContent = 0x33b0e0
    > <x-coredata:///DRAFT_CONTENT/tA2EE9788-F757-4A55-BF5D-7DC7122FBB9D>;
    > draftIsSentArticle = 0;
    > draftIsSuspended = 0;
    > draftLocked = 0;
    > draftMarkAndSendNextTime = 0;
    > draftMessageID = uid;
    > draftNewsgroups = nil;
    > draftProfile = -1;
    > draftReplyToID = nil;
    > draftSendLaterTime = nil;
    > draftSentDate = nil;
    > draftSignName = -1;
    > });
    > NSValidationErrorValue = <ANTStArticle_Content: 0x3314c0> (entity:
    > DRAFT_CONTENT; id: 0x33b0e0
    > <x-coredata:///DRAFT_CONTENT/tA2EE9788-F757-4A55-BF5D-7DC7122FBB9D> ;
    > data: {
    > messageBody = "";
    > messageHeaders = <040b7374 7265616d 74797065 6481e803 84014084
    >
    > 8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    > });
    > }
    >

    --
    www.malcom-mac.com - independent software developer
    mail: <malcom.mac...>
  • Your code is still incorrect.  Just looking at <http://pastebin.com/m38aa3280>...

    (1) Your -setMessageBody: method is not using the *change*
    notification methods, it is using the *access* notification methods.
    This is incorrect.

    (2) Your -messageBody: method is not using the access notification
    methods, it is just returning the result of -primitiveValueForKey:.
    This is incorrect.

    You have similar errors in the rest of your code, at least from
    looking at <http://pastebin.com/m65f42c4b>.  I strongly recommend
    reading up a bit more on how to write Core Data accessors and ensuring
    the correctness of your code with respect to the Core Data
    documentation.  I suspect that will help resolve the problem in your
    code a lot more quickly, and help prevent more problems of this kind
    from cropping up.

    You also have a grave error in your -[ANTStArticle
    initWithSubject:andReplyTo:] method; you are allocating another
    instance of ANTStArticle and assigning it to "self" in the method.
    Either you should write what it looks like you're trying to write as a
    class method (e.g. +articleWithSubject:replyTo:) or you should invoke
    the designated initializer on super without instantiating another
    ANTStArticle.

    Furthermore, you need to be aware that only your code will ever invoke
    your -initWithSubject:andReplyTo: method; Core Data will know nothing
    about it, and if Core Data itself is ever used to instantiate your
    DRAFT entity (say via an NSArrayController) it will simply invoke the
    designated initializer.  Any initialization that must happen when an
    instance of ANTStArticle is first inserted in a managed object context
    should go in an override of -awakeFromInsert.

    My specific recommendations for your code:

    (1) Rewrite the accessor methods for your modeled Core Data properties
    to invoke the -{will,did}{Access,Change}ValueForKey: methods
    correctly.  The -{will,did}AccessValueForKey: methods should be
    invoked in getters around -primitiveValueForKey:, while the -
    {will,did}ChangeValueForKey: methods should be invoked in setters
    around -setPrimitiveValue:forKey:.

    (2) Override -awakeFromInsert on ANTStArticle to perform any
    initialization that must always happen for instances of the DRAFT
    entity after they are inserted in a managed object context.  See the
    Core Data documentation for how to correctly override -
    awakeFromInsert; you need to invoke [super awakeFromInsert], and there
    are other issues you will probably need to consider as well.

    (3) Change -[ANTStArticle initWithSubject:andReplyTo:] to a class
    method +[ANTStArticle articleWithSubject:inReplyTo:] that returns a
    new autoreleased instance of your DRAFT entity, with whatever
    additional setup is correct for that entity.  In general, use +
    [NSEntityDescription
    insertNewObjectForEntityForName:inMangedObjectContext:] to create new
    instances of an entity, rather than +alloc/-
    initWithEntity:insertIntoManagedObjectContext:.  You will be more
    likely to write correct code that way.

      -- Chris

    On Oct 16, 2007, at 3:35 PM, malcom wrote:

    > ops.
    > Fixed a problem with custom accessor mehtod in ANTStArticle_Content.
    > Should be ok now (http://pastebin.com/m38aa3280).
    > But the problem persist.
    > Umpf where f* is the error? :((
    >
    > On 10/16/07, malcom <malcom.mac...> wrote:
    >>> Hell's Kitchen/Dexter/Malcolm:
    >>
    >> Hello Chris, I'm sorry but I've encountered some problems with my
    >> gmail account and apple ml so I've created another accounts.
    >>
    >> Well, regarding the problem I've created right (?) custom accessor
    >> methods but the problem persist. This is the code:
    >> ANTStArticle.m -> http://pastebin.com/m65f42c4b
    >> ANTStArticle_Content.m -> http://pastebin.com/m57644dd9
    >> While you can download the entire project here:
    >> http://www.mediafire.com/?5iyukzukm20
    >>
    >> The problem still to be this:
    >> NSError "draftContent is not valid." Domain=NSCocoaErrorDomain
    >> Code=1550 UserInfo={
    >> NSLocalizedDescription = "draftContent is not valid.";
    >> NSValidationErrorKey = draftContent;
    >> NSValidationErrorObject = <ANTStArticle: 0x3244d0> (entity: DRAFT;
    >> id: 0x336850 <x-coredata:///DRAFT/tCA7B7E93-3242-40D2-B324-6D3FF369E009
    >>>
    >> ; data: {
    >> draftConnection = -1;
    >> draftContent = 0x33b0e0
    >> <x-coredata:///DRAFT_CONTENT/tA2EE9788-F757-4A55-BF5D-7DC7122FBB9D>;
    >> draftIsSentArticle = 0;
    >> draftIsSuspended = 0;
    >> draftLocked = 0;
    >> draftMarkAndSendNextTime = 0;
    >> draftMessageID = uid;
    >> draftNewsgroups = nil;
    >> draftProfile = -1;
    >> draftReplyToID = nil;
    >> draftSendLaterTime = nil;
    >> draftSentDate = nil;
    >> draftSignName = -1;
    >> });
    >> NSValidationErrorValue = <ANTStArticle_Content: 0x3314c0> (entity:
    >> DRAFT_CONTENT; id: 0x33b0e0
    >> <x-coredata:///DRAFT_CONTENT/tA2EE9788-F757-4A55-BF5D-7DC7122FBB9D> ;
    >> data: {
    >> messageBody = "";
    >> messageHeaders = <040b7374 7265616d 74797065 6481e803 84014084
    >>
    >> 8484134e 534d7574 61626c65 44696374 696f6e61 72790084 840c4e53 4469>;
    >> });
    >> }
    >>
    >
    >
    > --
    > www.malcom-mac.com - independent software developer
    > mail: <malcom.mac...>
  • On Oct 16, 2007, at 7:58 PM, Chris Hanson wrote:

    > Your code is still incorrect.  Just looking at <http://pastebin.com/
    > m38aa3280>...
    >
    > (1) Your -setMessageBody: method is not using the *change*
    > notification methods, it is using the *access* notification
    > methods.  This is incorrect.
    >
    > (2) Your -messageBody: method is not using the access notification
    > methods, it is just returning the result of -
    > primitiveValueForKey:.  This is incorrect.
    >
    > You have similar errors in the rest of your code, at least from
    > looking at <http://pastebin.com/m65f42c4b>.  I strongly recommend
    > reading up a bit more on how to write Core Data accessors and
    > ensuring the correctness of your code with respect to the Core Data
    > documentation.  I suspect that will help resolve the problem in
    > your code a lot more quickly, and help prevent more problems of
    > this kind from cropping up.

    After reading and understanding the docs, it may also be a good idea
    to just use

    Copy Method Declarations to Clipboard
    Copy Method Implementations to Clipboard

    from the data modeler and use the generated methods/delcarations as a
    starting point to which you can add any necessary customizations.
    That will prevent inadvertent use of will/didAccessValueForKey when
    you should have been using will/didChangeValueForKey.

    Jim
  • > Your code is still incorrect.  Just looking at <http://pastebin.com/m38aa3280

    Thank you very much Chris, I'm sorry about my stupid questions, with
    your help now the code works. The main problem was with -init method
    for ANTStArticle_Content (and the same for ANTArticle) but I've also
    fixed the code with your suggestions.
    I've replaced it with:

    [NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext

    Again thank you. Have a nice day
    malcom
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today