Vikings
Vikings

Reputation: 2527

Type Cast UIView Warning

I keep getting a warning that the UIView may not respond to selectedSegmentIndex. I tried type casting, but I could not get rid of the warning. I'm assuming I did the cast incorrectly.

What is the proper way to type cast this, to avoid the warning?

- (IBAction)segmentedControlIndexChanged:(id)sender
{    
    switch ([[[[self.view viewWithTag:100] viewWithTag:202] viewWithTag:203] selectedSegmentIndex]) {

        case 0:
            // code here
            break;
        case 1:
            // code here
            break;
        default:
            break;
    }
}

Upvotes: 0

Views: 161

Answers (1)

Jonathan Naguin
Jonathan Naguin

Reputation: 14796

Try with this:

switch ([ (UISegmentedControl*)[[[self.view viewWithTag:100] viewWithTag:202] viewWithTag:203] selectedSegmentIndex]) {
...

Upvotes: 2

Related Questions