[Q] "auto"-incrementing integer attribute in awakeFromInsert
[Q] "auto"-incrementing integer attribute in awakeFromInsert
- Subject: [Q] "auto"-incrementing integer attribute in awakeFromInsert
- From: "Jon C. Munson II" <email@hidden>
- Date: Wed, 18 Mar 2009 11:52:52 -0400
- Organization: JTA Enterprises LLC
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@hidden)
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:
This email sent to email@hidden