Compile error on action for iPhone app: "error:expected ')' before ';' token"

Posted by Jamis Charles on Stack Overflow See other posts from Stack Overflow or by Jamis Charles
Published on 2009-07-01T03:18:23Z Indexed on 2010/04/19 8:43 UTC
Read the original article Hit count: 257

Filed under:
|

I'm working through the tutorials in the "Beginning iPhone Development" book. I'm on chapter 4 and I'm getting the following compile error on the "if (segment == kShowSegmentIndex)" line:

error:expected ')' before ';' token

Here's my code:

- (IBAction)toggleShowHide:(id)sender{
    UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
    NSInteger segment = segmentedControl.selectedSegmentIndex;

    if (segment == kShowSegmentIndex) [switchView setHidden:NO]; 
    else [switchView setHidden:YES];

}

I've compared it with the code in the book several times and have retyped it. Sounds like this error is caused by improper brace placement. Any thoughts?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c