Expected Specifier qualifier list error - iphone

Hey guys, I know this problem caused due to the absent of importing header
But in my case, I've included the header but I still got the error?! What happens?
#import <Foundation/Foundation.h>
#import "WikitudeARCustomMenuButtonDelegate.h"
#import "DetailedARViewController.h"
#interface CustomMenuButtonDelegateImpl1 : NSObject <WikitudeARCustomMenuButtonDelegate>
{
DetailedARViewController *ARViewController;
}
#end

Make sure that "DetailedARViewController.h" really does define DetailedARViewController; in particular, check for subtle errors like misspellings or a declaration accidentally commented out.

Related

Expected identifier or '(' error before #class

I have these 2 classes:
ViewController.h
#import <UIKit/UIKit.h>
#import "UICustomButton.h"
#interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>{
...
ViewController.m
#import "ViewController.h"
#implementation ViewController
...
UICustomButton.h
#import <UIKit/UIKit.h>
#class ViewController;
#interface UICustomButton : UIButton{
...
UICustomButton.m
#import "UICustomButton.h"
#import "ViewController.h"
#implementation UICustomButton
...
And I get the following errors
1 Expected identifier or '(' - in file UICustomButton.h just before #class
2 Expected ')' - also there
3 Expected a type - when I try to use ViewController in UICustomButton.h
4 in UiCustomButton.m I also get the error
After two hours of googling and trying, I just can't see the problem. Can you please help?
SOLUTION:
Rewriting everything was a good ideea. It made me see that in the file ViewController.m I had accidentally typed a paranthesis '(' on top at the beginning of the file. The compiler didn't poit it out, only UICustomButton.H generated errors.
Don't be afraid to restart/scrap and recreate a class. As you gain more experience correcting complex errors becomes a lot easier.
I'm completely serious about you needing to restart creating this class. Since apparently you can't interpret the message that the compiler is telling you it will take much longer for you to figure out the issue than creating another class, copying the business logic there and deleting the current implementation. Your choice, spend 10 minutes recreating the file or spend another who knows many hours trying to get the syntax Ok.
Even the professionals feel it a strong tool to restart when it's needed. Marshall Huss from Treehouse explains in this podcast why it was preferrable for him too.
PS: and best, you can rename the new class to the old name once you're done.
Looks like you are misspelling ViewController.h. You have Viewcontroller.h in your #import line

Cannot find protocol declaration for 'NSPasteboardWriting'

I am getting this error
Cannot find protocol declaration for 'NSPasteboardWriting'
i have created the class
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#interface ErrorLog : NSObject<NSCoding, NSPasteboardWriting, NSPasteboardReading> {
}
#end
Can any one tell me that whether i am missing some header file or whats the reason for that?
NSPasteboardWriting is Available in Mac OS X v10.6 and later.
check your project setting(Base SDK).
Import the header file in which NSPasteboardWriting and NSPasteboardReading protocols are declared. Also make sure you have the protocols in the class specified.

Unknown Expected identifier

I have taken over a project and am fairly new to cocotouch. I was looking throught the code trying to understand things. I didn't think I changed anything but when I went to run It came up with three build errors (it had run just a few minutes before with no problems). The second two seemingly related to the first:
#import <UIKit/UIKit.h>
#protocol MapViewDelegate; //Expected identifier or '(' before 'protocol'
#interface MapView : TTImageView
{
id<MapViewDelegate> mv_delegate; //Cannot find protocol declaration for 'MapViewDelegate'
}
#property (assign) id<MapViewDelegate> mv_delegate; //Cannot find protocol declaration for 'MapViewDelegate'
#end
#protocol MapViewDelegate <NSObject>
- (void)mapView:(MapView *)mv pressedAt:(CGPoint)point;
- (void)mapViewFinishedLoading:(MapView *)mv;
#end
I am using XCode4 which I have just switched to but have had working since the switch.
What is going on here?
MapKit.framework has been added to the project?

Protocol definition not found

I am having a little trouble with getting a protocol definition to work, and this must be a stupid mistake. I included the header in which the definition is located, but I got the warning, so followed the advice to create a separate header file. I still get the warning that the definition cannot be found (when importing this separate file), and even when I put the definition in the header file of the class using it it gives the warning:
#protocol SubstitutableDetailViewController <NSObject>
- (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem;
- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem;
#end
#interface LauncherViewController :TTViewController<SubstitutableDetailViewController, TTLauncherViewDelegate> {
TTLauncherView *launcherView;
}
So what do I do wrong in my definition of the protocol?
[EDIT: Sorry, there must be an oddity in Xcode, or I am going mad, I did a clean build and now the warning does not come back... but I don't know why]
Put this code in a separate file named SubstitutableDetailViewController.h (I'd prefer SubstitutableDetailViewControllerDelegate.h):
#protocol SubstitutableDetailViewController <NSObject>
- (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem;
- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem;
#end
And then include it in LauncherViewController via #import "SubstitutableDetailViewController.h"

The same error i all headers - error: expected '='... before 'protocol'

I've been working on an iOS project for some time but now I have an error which really confuses me and as long as I can't fix it I can't even compile the project so I need some serious help!
It all began with an:
error: expected '=', ',', ';', 'asm' or 'attribute' before 'protocol'
in PHCluesListViewController.h. The class had not been changed for a long time and what I was working on at the moment of the error had nothing to do with that particular class.
This is what it looks like:
#import <UIKit/UIKit.h>
#protocol PHCluesListViewControllerDelegate;
#class PHClueListTableViewController;
#interface PHCluesListViewController : UIViewController {
IBOutlet PHClueListTableViewController *clueListTableViewController;
id <PHCluesListViewControllerDelegate> delegate;
}
- (void)mapDelegate;
#property (nonatomic, assign) id <PHCluesListViewControllerDelegate> delegate;
#end
#protocol PHCluesListViewControllerDelegate
- (void)mapUp:(PHCluesListViewController *)controller;
#end
There are no syntax errors and there is nothing wrong with the code in it's context either. Later I would learn that if you were to take away all the code from the header file the error would move to a another random header file or if you were to import another header the error would move to this header.
I've tried to restart xcode, to move the project to a new one, to rewrite the code to a new file and to move the project to another computer with another version of xcode - but with no luck.
I am able to run other xcode-projects on my computer.
It seems to me that xcode are trying to compile my headers in this specific project in some unwanted fashion.
Help would be highly appreciated, thanks on before hand!
---------- EDIT!!! ----------
Thanks for the fast respond!! Although I've found the answer.
The error was a "d" written out of bounds of the implementation in a totally different file/class. Found it by chance...
If something similar would happen to anyone else; check for something like a letter written after #end or before #interface/#implementation or anything else that would "cut the edges" of the common syntax.
It's difficult to find the reason for an error like this and I'm a little bit surprised that I found it so quickly among 80 files (only 4.5 hours).
Good luck!!
You're defining #protocol PHCluesListViewControllerDelegate twice. Also, if mapUp is required to be implemented, you might want to add the #required keyword.