Search code examples
iphoneiostabbaruitabbaritem

uncaught exception : -{WebDataSource indexof:]: unrecognized selector while using framework


 - (void)ItemPressed:(id)sender {
    NSInteger index = [self.tabBarItems indexOfObject:sender];
    BOOL shouldSelect = [self delegatedDecisionIfWeShouldSelectViewController:[self.viewControllers objectAtIndex:index] atIndex:index];

    if (shouldSelect) {
        if (index != self.selectedIndex) {
            self.selectedIndex = index;
        } else {
            if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) {
                UINavigationController *navigationController = (UINavigationController *)self.selectedViewController;

                [navigationController popToRootViewControllerAnimated:YES];
            }
        }
    }
}

Hi I am Created tabbarcontroller framework all working fine using source but created framework getting error while selecting one index to another

-{WebDataSource indexof:]: unrecognized selector instance i got the above error.

any thoughts?

i declared tabbar items like below

vc1 = [[webviewname alloc] initUrl:[NSURL URLWithString:@"https://www.google.com"]];
    vc2 = [[webviewname  alloc] initUrl:[NSURL URLWithString:@"https://www.yahoo.com"]];

    vc1.O_tabBarItem = [OTabBarItem itemWithTitle:@"index" image:[UIImage imageNamed:@"index"]];
    vc2.O_tabBarItem = [OTabBarItem itemWithTitle:@"index" image:[UIImage imageNamed:@"index"]];


    vc1.delegate=self;
    vc2.delegate=self;

    NSArray *vControl = [NSArray arrayWithObjects:vc1,vc2,nil];

Solution

  • I hope you expected self.tabBarItems to be an NSArray object. But here, the object refers some other instance, say instance of WebDataSource.

    Is it possible to show, how you have declared and populated the array tabBarItems ?