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

  • Home
  • SEARCH
  • 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 6775181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:52:35+00:00 2026-05-26T15:52:35+00:00

Am having some trouble with a simple callback; am getting an ‘expected method body’

  • 0

Am having some trouble with a simple callback; am getting an ‘expected method body’ error even though I can’t find anything wrong. Have commented the error messages.

Logger.h

#import <Foundation/Foundation.h>

@interface Logger : NSObject

- (void)sayOuch:NSTimer *)t; // Expected ';' after method prototype

@end

Logger.m

#import "Logger.h"

@implementation Logger

- (void)sayOuch:NSTimer *)t // expected method body
{
    NSLog(@"Ouch!");
}

@end

main.m

#import <Foundation/Foundation.h>
#import "Logger.h"

int main (int argc, const char * argv[])
{

    @autoreleasepool {

       Logger *logger = [[Logger alloc]init];

       NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2.0 
                                                      target:logger 
                                                    selector:@selector(sayOuch:) 
                                                    userInfo:nil 
                                                     repeats:YES]; 

        [[NSRunLoop currentRunLoop]run]; 

    }
    return 0;
}
  • 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-05-26T15:52:35+00:00Added an answer on May 26, 2026 at 3:52 pm

    You have

    - (void)sayOuch:NSTimer *)t;
    

    But you should have

    - (void)sayOuch:(NSTimer *)t;
    

    You missed the opening parenthesis for NSTimer *

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

Sidebar

Related Questions

I am having some trouble getting this simple code to work: #pragma once #include
Im having some trouble with a simple form. I can't seem to prevent the
I'm building my first simple Windows Phone app. I'm having some trouble though. I'm
Having some trouble with what should be a very simple scenario. For example purposes,
I'm having some trouble with Visual Studio 2008. Very simple program: printing strings that
I'm new to linq and having trouble writing two simple queries. For some reason,
I'm having quite some trouble with the WCF Callback mechanism. They sometimes work but
I'm trying to write a simple integration test, but having some trouble with Domain
Having some trouble using basic authentication with a simple test Wcf service. I am
I am having some trouble with jQuery. I am making a simple CMS and

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.