Permalink
Browse files

Added observation context to KTTabViewController

  • Loading branch information...
1 parent 5199eb0 commit 4383b949ad37f3f75a54651d961c89024b307d23 Jonathan Dann committed Nov 2, 2010
Showing with 14 additions and 10 deletions.
  1. +13 −10 Framework/Controllers/KTTabViewController.m
  2. +1 −0 KTUIKit.xcodeproj/project.pbxproj
@@ -35,6 +35,8 @@ @implementation KTTabViewController
@synthesize shouldResizeTabViews = mShouldResizeTabViews;
@synthesize delegate = wDelegate;
+static void *_KTTVCTabItemArrayControllerSelectionIndexObservationContext = (void *)@"_KTTVCTabItemArrayControllerSelectionIndexObservationContext";
+
//===========================================================
// - initWithNibName:bundle:windowController
//===========================================================
@@ -54,7 +56,7 @@ - (id)initWithNibName:(NSString*)theNibName bundle:(NSBundle*)theBundle windowCo
// we let this view controller manage selection for us
mTabItemArrayController = [[NSArrayController alloc] init];
[mTabItemArrayController setSelectsInsertedObjects:YES];
- [mTabItemArrayController addObserver:self forKeyPath:@"selectionIndex"options:0 context:nil];
+ [mTabItemArrayController addObserver:self forKeyPath:@"selectionIndex"options:0 context:&_KTTVCTabItemArrayControllerSelectionIndexObservationContext];
[self setShouldResizeTabViews:YES];
}
@@ -90,16 +92,17 @@ - (KTView *)view
//===========================================================
- (void)observeValueForKeyPath:(NSString *)theKeyPath ofObject:(id)theObject change:(NSDictionary *)theChange context:(void *)theContext
{
- if(theObject == mTabItemArrayController)
+ if(theContext == &_KTTVCTabItemArrayControllerSelectionIndexObservationContext)
{
- if([theKeyPath isEqualToString:@"selectionIndex"])
- {
- NSInteger aSelectedIndex = [mTabItemArrayController selectionIndex];
- KTTabItem * aNewTabToSelect = nil;
- if(aSelectedIndex!=NSNotFound)
- aNewTabToSelect = [[mTabItemArrayController arrangedObjects] objectAtIndex:aSelectedIndex];
- [self _selectTabItem:aNewTabToSelect];
- }
+ NSInteger aSelectedIndex = [mTabItemArrayController selectionIndex];
+ KTTabItem * aNewTabToSelect = nil;
+ if(aSelectedIndex!=NSNotFound)
+ aNewTabToSelect = [[mTabItemArrayController arrangedObjects] objectAtIndex:aSelectedIndex];
+ [self _selectTabItem:aNewTabToSelect];
+ }
+ else
+ {
+ [super observeValueForKeyPath:theKeyPath ofObject:theObject change:theChange context:theContext];
}
}
@@ -937,6 +937,7 @@
isa = PBXProject;
buildConfigurationList = C056398B08A954F8003078D8 /* Build configuration list for PBXProject "KTUIKit" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,

0 comments on commit 4383b94

Please sign in to comment.