Re: Saving a core data model to persistent store makes application hang
Re: Saving a core data model to persistent store makes application hang
- Subject: Re: Saving a core data model to persistent store makes application hang
- From: Bill Bumgarner <email@hidden>
- Date: Sun, 26 Nov 2006 09:21:15 -0800
First -- you should sample your app when it is in an infinite loop
and post the sample (or use gdb to grab a backtrace).
Several problems with the code:
- (void)awakeFromFetch {
[super awakeFromFetch];
NSString *rectString=[self valueForKey:@"boundsAsString"];
if(rectString!=nil) {
bounds=NSRectFromString(rectString);
}
}
Use your setter method so the KVO notifications are sent properly.
Depending on your model, this could also be hosing the context's
state management stuff. Speaking of the model, the names of some of
your attributes are a bit odd. "child_yes" doesn't really say "the
set of children considered to be in the 'yes' state'. How about
'yesChildren' and 'noChildren'? (yes, pedantic, I know.)
In general, you should probably keep the bounds and boundsAsString
attributes in sync. Or more carefully track when they are not. I
haven't looked at the code closely, but a quick glance would indicate
that there may be situations where the two could fall out of sync,
leading to problems.
Your add and remove methods seem overly complex at first glance.
Why not just:
- (void)removeYesChild:(MSChartElement *)value
{
[[self mutableSetValueForKey: @"yesChildren"] removeObject: value];
}
... etc ...
- (void) setNilValueForKey:(NSString *) key {
[self setValue:[NSValue valueWithRect: NSMakeRect(0,0,0,0)]
forKey:key];
}
This is a bit scary. It means that *any* key set with a nil value is
going to get a string representation of the {0,0,0,0} rect. Probably
not what you want.
b.bum
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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