Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior
Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior
- Subject: Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior
- From: Jerry Krinock <email@hidden>
- Date: Wed, 25 Feb 2009 05:12:29 -0800
On 2009 Feb 24, at 21:17, Karolis Ramanauskas wrote:
Any thoughts?
I downloaded your project and inserted the code that I gave you
yesterday into your -[MyView doSomething] method. From the log, I
then learned that the Fruit I inserted was being updated. Here's what
happens:
1. You move the mouse over your view.
2. As you move the mouse, Cocoa needs to redraw the area of your
view which
^was^ covered by the mouse cursor/arrow.
3. So, Cocoa invokes -[MyView drawRect:]
4. -[MyView drawRect:] invokes -[Fruit draw]
5. -[Fruit draw] invokes setName: on itself
6. which causes an
NSManagedObjectContextObjectsDidChangeNotification
7. which is observed and runs -[MyView doSomething:]
Go to fruit class, comment out: [self setName:@"Banana"];
... problem is gone.
Yes, you've eliminated reaction 5 from the above.
Everything is behaving as expected. You fixed it. You're done.
Lesson: Don't change model data in a -draw method. I really can't
think of any reason why you'd want to do this. -draw is for drawing.
_______________________________________________
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