NSArrayController issue
NSArrayController issue
- Subject: NSArrayController issue
- From: Måns Severin <email@hidden>
- Date: Thu, 1 May 2008 23:09:50 +0200
Hi,
I've been working with an NSArrayController containing CoreData entity
objects.
I've created a segmented control for cycling through these object
(similar to Safari's Back/Forward buttons).
For some reason, after calling the NSArrayController methods
selectNext: and selectPrevious: from my controller object, the
canSelectNext and canSelectPrevious controller keys doesn't reflect
the new selection.
In the code i provide I have a stepProjects: action called from the
segmented control (oStepper), it calls the oProjectsController to
select next/previous records. It then updates the UI which sets
enabled flags for the segments in the segment control. Problem is,
canSelectPrevious and canSelectNext does not return correct value even
if the array controller has selected the first or last element. If I
instead of the [self updateUI] call create an NSTimer object, which in
turn does an updateUI call after a 0.2 second delay, I get a correct
update of the segment control.
Is there some kind of delegate / observer method of the
NSArrayController to see when it is done changing selection?
I wouldn't have had this problem if I could bind the segments directly
in Interface Builder, but I am not able to do that.
Anyone have had the same issue?
Best Regards
Måns Severin
Code Listing:
- (void)updateUI
{
[self updateStepper];
}
- (IBAction)stepProjects:(id)sender
{
switch ( [oStepper selectedSegment] )
{
case 0:
[oProjectsController selectPrevious:self];
break;
case 1:
[oProjectsController selectNext:self];
break;
}
[self updateUI];
}
- (void)updateStepper
{
[oStepper setEnabled:[oProjectsController canSelectPrevious]
forSegment:0];
[oStepper setEnabled:[oProjectsController canSelectNext] forSegment:1];
}_______________________________________________
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