RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
- Subject: RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
- From: "Jon C. Munson II" <email@hidden>
- Date: Mon, 6 Apr 2009 14:10:38 -0400
- Organization: JTA Enterprises LLC
Namaste!
I realize this reply is a bit later in the calendar, however, I finally had
time to tryout the default "for free" undo from the managedObjectContext.
What I found is that Undo will first undo the auto-increment, a second,
subsequent, undo will then Undo the Add. One exception to this is when one
is entering the "first" record (starting with no records) - then it seems to
undo the whole deal. I tested both on a form where a textfield was bound to
the ID, and also a tableview where the first column was bound to the ID
field.
So, I agree Sean that the auto-increment set is being done in a different
"pass" than the actual add.
However, it seems adding a record can be undone (and redone presumably) -
just need to press Undo twice.
While that works, I don't think it is the right way to do things. And, one
shouldn't have to sprinkle custom Undo/Redo code everywhere just to bundle
the two actions together. This could be a major headache if an add causes
all kinds of child-adds too.
Any reason why I shouldn't file an enhancement request?
Peace, Love, and Light,
/s/ Jon C. Munson II
> -----Original Message-----
> From: Sean McBride [mailto:email@hidden]
> Sent: Friday, March 20, 2009 8:15 PM
> To: email@hidden; 'Cocoa Developers'
> Subject: Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
>
> On 3/19/09 10:09 AM, Jon C. Munson II said:
>
> >I did some digging and found that the real issue is the call for
> >processPendingChanges that apparently is called via the executeFetch.
> >According to what I read this is standard behavior.
> >
> >So, I'd have to say it isn't a "bug" in this case.
>
> Well, 'bug' can mean many things. :) Months ago, I used a DTS incident
> on this topic, and was told by DTS that the 'item appearing twice in the
> table if you fetch in awakeFromInsert' situation (that you saw) is a bug
> in NSArrayController.
>
> I agree with you that it is kludgy to have to use
> performSelector:withObject:afterDelay:. Such a situation is exactly
> when you should file a bug/enhancement request.
>
> Have you tested undo after switching to
> performSelector:withObject:afterDelay:? You may find that undo will
> only undo the setting of the 'auto-incremented' integer attribute. I
> suspect this is because performSelector:withObject:afterDelay: runs on a
> different pass through the event loop.
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng email@hidden
> Rogue Research www.rogue-research.com
> Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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