0

I have four tabViewItems, with identifiers 1, 2, 3, and 4 assigned in IB, and then set up as constants, i.e.:

#define kTabViewSubject     1

When testing which tabViewItem is selected, it works to treat the identifiers as NSNumbers, like this:

if ([self.drawerTabView selectedTabViewItem] identifier] intValue]]] == kTabViewSubject])
// do something

But when selecting a tabViewItem, if I treat the same identifier as an NSNumber, like this…

[self.drawerTabView selectTabViewItemWithIdentifier:[NSNumber numberWithInt:kTabViewSubject]];

… the identifier is evaluated as a huge address-like number and I get a “beyond bounds” exception.

What works is to treat the identifier as an NSString, like this:

#define kTabViewSubjectX        @"1"
// --
[self.drawerTabView selectTabViewItemWithIdentifier:kTabViewSubjectX];

I understand NSTabViewItem’s identifier property is set up as a generic “id.” But why is it inconsistently classed?

Wienke
  • 3,723
  • 27
  • 40

1 Answers1

0

intValue is a method of NSString as well as NSNumber. The identifiers were strings all along.

Wienke
  • 3,723
  • 27
  • 40