Namaste!

I'm having a little trouble getting a self-incrementing attribute to work in
the awakeFromInsert override.  After perusing the dox and Googling, I'm
stumped on it.

Here's my code (abbreviated):

-(void)awakeFromInsert
{
        int numĀ  = 0;

        NSArray *a;
        NSManagedObjectContext *moc = ...;
        NSEntityDescription *entity = ...;
        NSFetchRequest *request = ...;
        NSError *e = ...;

        a = [moc executeFetchRequest...];

        if( a != nil )
        {
                num = [[a valueForKeyPath:@"@max.attribute"] integerValue];
        }

        num += 1;

        [self setPrimitiveValue:[NSNumber numberWithInt:num]
forKey:@"attribute"];
}

What happens is the attribute is set with the correctly incremented number.
However, the tableview that is used to manage this entity displays two rows
every time a new entity is inserted.

I saw (after much Googling) that someone else had a similar problem (and
appeared to have identified the issue as having to do with the fetch itself,
I did not verify this) but implemented a different solution which won't work
in my case.

So, my question is, how do I resolve the two-row error, or, is there a
better way?

Many thanks in advance!

Peace, Love, and Light,

/s/ Jon C. Munson II


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to