Search code examples
swiftintegeruitabbarcontrollerselectedindex

Swift 2.1- tabBarController!.selectedIndex return massive integer


I am needing to put the tabBarController!.selectedIndex number inside a constant.

I am expecting a number between 0 and 3 depending on what tab I choose, but instead I get numbers like 2147483647

Any ideas why this is?

The code is:

let selectedTab = tabBarController!.selectedIndex
print(selectedTab)

Solution

  • That value is NSNotFound. In this case it seems to represent "no selection".