First post, and I really hope this is not a recurring or resolved issue. I tried to find Google here, and although I found similar errors, Expected identifier or '(' , none of the solutions work for me.
Basically I try to learn design patterns, and since I knew a little java, I try to use it as an opportunity to learn objective-c, so I have a working Java program and an xCode project that I will get Expected identifier or '(' in my header file just before @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 version of objective-c.
//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>
If anyone can help, I would really appreciate it, and again sorry if this is a duplicate of the message
source share