Force arrayController to remove immediately?
Force arrayController to remove immediately?
- Subject: Force arrayController to remove immediately?
- From: Justin Hawkwood <email@hidden>
- Date: Sat, 16 Feb 2008 12:31:56 -0800
I have an array controller bound in the NIB to a Core Data Entity, and
a function to remove the selected item (from tableview) through that
array controller. The problem is that I want to rescan the array
controller to set some other variables based on the remaining items in
the array, but since the "remove" function is delayed, the item for
removal is still in the array until the next run loop.
From the Apple doc for NSArrayController:
Special Considerations
Beginning with Mac OS X v10.4 the result of this method is deferred
until the next iteration of the runloop so that the error
presentation mechanism can provide feedback as a sheet.
My functions:
- (IBAction)removeProfileEntry:(id)sender
{
[profileEntryController removeObjects:[profileEntryController
selectedObjects]];
[self updateTime];
// [NSTimer scheduledTimerWithTimeInterval:0.01 target:self
selector:@selector(updateAllStats)
// userInfo:nil repeats:NO];
}
- (void) updateTime
{
// "profile" is a subset from profileEntryController
NSMutableSet *profile = [[[diveArrayController selectedObjects]
objectAtIndex:0] valueForKey:@"profileData"];
NSSet *aSet = [profile valueForKey:@"time"];
if ((aSet != nil) && ([aSet count] != 0)) {
float max = 0.0;
NSEnumerator *enumerator = [aSet objectEnumerator];
id value;
while ((value = [enumerator nextObject])) {
if ([value floatValue] > max) max = [value floatValue];
}
[[[diveArrayController selectedObjects] objectAtIndex:0] setValue:
[NSNumber numberWithFloat:max]
forKey:@"diveTime"];
}
}
Run as is, the removed object is still included when updateTime is
called. If I use the timer instead, in removeProfileEntry, then
updateTime functions properly, but it creates a separate undo event,
which I don't want.
How do I force the removal to take place immediately, or is there a
notification I can watch for that tells me the removal has completed,
and then run the updateTime method?
~ Justin
_______________________________________________
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