Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:46:42+00:00 2026-06-02T11:46:42+00:00

Am getting an Expected expression error but can’t figure out why on an IBAction

  • 0

Am getting an “Expected expression” error but can’t figure out why on an IBAction method. Have commented out the error.

Can you tell me what’s wrong? Thank you.

#import "RTViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>

@interface RTViewController () {
  AVAudioPlayer *backgroundAudioPlayer;
  SystemSoundID burnRubberSoundID;
  BOOL touchInCar;
}

@end

@implementation RTViewController
@synthesize car;
@synthesize testDriveButton;
@synthesize backgroundImage;

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"Road Trip";

  NSURL* backgroundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                                 pathForResource:@"CarRunning" 
                                                 ofType:@"aif"]];
  backgroundAudioPlayer = [[AVAudioPlayer alloc]
                           initWithContentsOfURL:backgroundURL error:nil];
  backgroundAudioPlayer.numberOfLoops = -1;
  [backgroundAudioPlayer prepareToPlay];

  NSURL* burnRubberURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"BurnRubber" ofType:@"aif"]];
  AudioServicesCreateSystemSoundID((__bridge CFURLRef)burnRubberURL, &burnRubberSoundID);
  [testDriveButton setBackgroundImage:[UIImage animatedImageNamed:@"Button" duration:1.0 ] forState:UIControlStateNormal];

}

- (void)viewDidUnload
{
    [self setCar:nil];
    [self setTestDriveButton:nil];
    [self setBackgroundImage:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  //return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)TestDrive:(id)sender {
  AudioServicesPlaySystemSound(burnRubberSoundID);
  [self performSelector:@selector(playCarSound) withObject:self afterDelay:.2];

  CGPoint center = CGPointMake(car.center.x, self.view.frame.origin.y + car.frame.size.height/2);
  [UIView animateWithDuration:3 animations:^ {
    car.center = center;
  }
                   completion:^(BOOL finished) {
                     [self rotate];
                   }];
}

-(void)playCarSound {
  [backgroundAudioPlayer play];
}

- (void)rotate {
  CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI);

  void (^animation) () = ^() {
    car.transform = transform;
  };

  void (^completion) (BOOL) = ^ (BOOL finished) {
    [self returnCar];
  };

  [UIView animateWithDuration:3 animations:animation completion:completion];

}

- (void)returnCar {
  CGPoint center = CGPointMake(car.center.x, self.view.frame.origin.y + self.view.frame.size.height - car.frame.size.height/2);

  void (^animation)() = ^() {
    car.center = center;
  };

  void (^completion)(BOOL) = ^(BOOL finished) {
    [self continueRotation];
  };


  [UIView animateWithDuration:3 animations:animation completion:completion];

}

- (void)continueRotation {
  CGAffineTransform transform = CGAffineTransformMakeRotation(0);

  void (^animation)() = ^() {
    car.transform = transform;
  };

  void (^completion)(BOOL) = ^(BOOL finished) {  
    [backgroundAudioPlayer stop];
    [backgroundAudioPlayer prepareToPlay];
  };


  [UIView animateWithDuration:3 animations:animation completion:completion];

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  UITouch *touch = [touches anyObject];
  if(CGRectContainsPoint(car.frame, [touch locationInView:self.view]))
    touchInCar=YES;
  else {
    touchInCar=NO;
    [super touchesBegan:touches withEvent:event];
  }

  UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeGesture:)];
  swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft;
  [self.view addGestureRecognizer:swipeGesture];

  - (IBAction)handleSwipeGesture:(id)sender { // Expected expression

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"Content"];
    [[self navigationController]pushViewController:viewController animated:YES];
  }
}
@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:46:45+00:00Added an answer on June 2, 2026 at 11:46 am

    The problem is that you never closed out the method

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    

    with its own curly brace. One visual cue is that the method

    - (IBAction)handleSwipeGesture:(id)sender
    

    (where your error is) starts out indented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to figure this out! I keep getting an error that says
Getting Expected ',' or '{' but found '#44559' error. My code looks like this:
I'm currently getting the following compile errors: In function 'int main()': error: expected primary-expression
I am getting an error as expected expression before '=' token. #define RMH_MAX_UNENCODED_LENGTH= (RMH_MESSAGE_MAX_SIZE
I expected this to compile, but I kept getting the error The type of
I am having some trouble getting expected results out of the zip command. Cases
I keep getting an expected identifier error at this line in my code =/
I keep on getting this error error: expected specifier-qualifier-list for core data code im
I tried it but I am getting this error: Server Error in '/' Application.
I am getting the following error: exercise-2-2.hs:15:49: Couldn't match expected type `Double' with actual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.