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 8433915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:31:02+00:00 2026-06-10T06:31:02+00:00

First post and I am really hoping this is not a repetitive or solved

  • 0

First post and I am really hoping this is not a repetitive or solved question. I tried searching here and Google and while I have found similar Expected identifier or '(' errors none of the solutions work for me.

Basically I’m trying to learn Design patterns and as I used to know a bit of java I am trying to use it as an opportunity to learn objective-c so I have a java program that works and an xCode project that I get the error Expected identifier or '(' in my header file just before the @interface

this is my java solution (very simple I know):

public class Duck {

public void quack(){
        System.out.print("Quack!");

    }
    public void swim(){
        System.out.print("swimming duck!");
    }
public void display(){
    quack();
    swim();
        }

    }
public class mainClass {
    public static void main(String[] args){
        Duck duck = new Duck();
        duck.display();
    }
}

and this is my objective-c version.

//duck.h
#include <CoreFoundation/CoreFoundation.h>

@interface Duck : NSObject{ //Expected identifier or '('

}
@end

//  Duck.m
#include "Duck.h" 
@implementation Duck
-(void)quack{
    printf("Quack!");
}
-(void)swim{
    printf("swimming duck!");
}

-(void)display{
    [self quack];
    [self swim];    
}
@end

//  main.c
#include <CoreFoundation/CoreFoundation.h>
#include "Duck.m"

int main(int argc, const char * argv[])
{
    Duck *duck = [[Duck alloc] init];
    [duck display];
    return 0;
}

If any one can help I would greatly appreciate it, and again sorry if this is a duplicate post

  • 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-10T06:31:03+00:00Added an answer on June 10, 2026 at 6:31 am
    //duck.h
    //#include <CoreFoundation/CoreFoundation.h>
    #import <Foundation/Foundation.h> // or Cocoa/Cocoa.h
    
    @interface Duck : NSObject//{ //Expected identifier or '('
    
    //} not necessary if there are no instance fields
    - (void)quack;
    - (void)swim;
    - (void)display;
    @end
    
    //  Duck.m
    //#include "Duck.h"
    #import "Duck.h" 
    @implementation Duck
    -(void)quack{
        printf("Quack!");
    }
    -(void)swim{
        printf("swimming duck!");
    }
    
    -(void)display{
        [self quack];
        [self swim];    
    }
    @end
    
    //  main.c SHOULD BE ~main.m~ if using ObjC!!!
    //#include <CoreFoundation/CoreFoundation.h>
    //#include "Duck.m"
    #import "Duck.h"
    

    Additionally, get in to the habit of using NSString literals; @”example” for if/and when you decide to advance into Cocoa. Good luck with your studies.

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

Sidebar

Related Questions

Well, this is my first post here and really enjoying the site. I have
this is my very first post! I have a quick question in regarding inheritance
This is my first post here. My question is similar to a previous thread
This is my first post here so kindly pardon any mistakes that I have.
My first post here :) I have a summer job doing a bit of
My first post here, so i hope this is the right area. I am
This is my first post and I my first experience with jquery. I have
This is my first post on stackoverflow, so please excuse me if my question
Frequent visitor but first post here on StackOverflow, I'm hoping that you guys might
first post, so play nice! I have a fairly basic question about Python dictionaries.

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.