Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 6, 2011, 03:54 PM   #1
Avicenna
macrumors member
 
Join Date: Jul 2009
No storage class may be specified (Objective-c ) error

Hi,
I have been trying to figure out this error for the past 3 days. Simply don't understand what's wrong. I get this error with my Utilities.h class:


Code:
error: no type or storage class may be specified here before 'interface'
I posted this in more detail in stackoverflow but it was no help either. Please check it out : http://stackoverflow.com/questions/6...ective-c-error


Here's the .h file for Utilities:

Code:
#import <Foundation/Foundation.h>

@interface Utilities : NSObject {

}

+ (NSString *)getDocumentsDirectory;
+ (void)showActivityIndicator;
+ (void)hideActivityIndicator;
+ (void)setUser:(NSString *)userName withPassword:(NSString *)password;
+ (NSString *)getUserName;
+ (NSString *)getPassword;
+ (long long)generateTicketNumber;
+ (BOOL)reachable;
+ (NSString *)printerAddress;
+ (NSInteger)port;
+ (void)setAddress:(NSString*)newAddress andPort:(NSInteger)newPort;
+ (void)showDataActivity;



@end
I reduced the .m file to a mere:
Code:
#import "Utilities.h"

@implementation Utilities

@end
Of course, I get warnings that the methods aren't implemented. But the error of "No type or storage..." still remains.

Thanks.

Last edited by Avicenna; Jul 6, 2011 at 04:11 PM.
Avicenna is offline   0 Reply With Quote
Old Jul 6, 2011, 03:56 PM   #2
robbieduncan
Demi-God (Moderator)
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Don't post links to the same question elsewhere. Either ask it here or don't ask. Post the entire code (not a screenshot, copy and paste) for your .h file.
robbieduncan is offline   0 Reply With Quote
Old Jul 6, 2011, 04:12 PM   #3
Avicenna
Thread Starter
macrumors member
 
Join Date: Jul 2009
Quote:
Originally Posted by robbieduncan View Post
Don't post links to the same question elsewhere. Either ask it here or don't ask. Post the entire code (not a screenshot, copy and paste) for your .h file.
Alright. Updated my original post, please check it out.
Avicenna is offline   0 Reply With Quote
Old Jul 6, 2011, 04:18 PM   #4
robbieduncan
Demi-God (Moderator)
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
I have tried creating a new Command Line Foundation tool and added your Utilities to it via copy and paste. I get no such error. I suspect you have a non-printable character that has meaning or something similar. Try moving Utilities.h to a new file name and creating a new file via copy and pasting the .h you posted to this site.
robbieduncan is offline   0 Reply With Quote
Old Jul 6, 2011, 04:20 PM   #5
chown33
macrumors 601
 
Join Date: Aug 2009
When I copy and paste your provided source into suitable files and compile here, they compile with no errors, only the warnings about incomplete implementation of class 'Utilities'. Therefore, I suspect nothing is syntactically wrong with the posted source code.

I suspect there may be some invisible characters in your actual source file. Or perhaps you have damaged something in Foundation/Foundation.h. Or perhaps you have some unexpected search-path for #includes that is including the wrong Foundation.h.

If there are invisible characters in your actual file, we won't be able to see them simply by you pasting code into posts. You'll have to compress and upload the actual files.

Or you could use a hex editor such as Hex Fiend (google it) to inspect your source files for unexpected characters.

Depending on which Xcode version you're using (3.x would be suitable, 4.x I don't know), you can choose Build > Preprocess and inspect the result to see if there's something unexpected after the expanded #import of Foundation.h, directly before your @interface.

EDIT
Another thing occurred to me: you might have an unexpected macro expansion appearing before your @interface, triggered by what you think is an innocuous word or term, but which the preprocessor is expanding into something that doesn't compile correctly.

It's slightly odd that you're getting a specific "type or storage class" error. If there were uninterpretable invisible characters, I might expect a complaint about an unexpected character. But if the preprocessor is doing a macro substitution, and that leads to a syntax error, then the actual error isn't at the @interface, but at some location before it. If the actual source is exactly as posted, then that can only be at the end of the expanded #import of Foundation.h. However, if there is actually some other text between the #import and the @interface, then that could be causing the error and you've simply not bothered to post it because you believed it to be harmless.

Last edited by chown33; Jul 6, 2011 at 04:48 PM.
chown33 is offline   0 Reply With Quote
Old Jul 6, 2011, 04:47 PM   #6
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Quote:
Originally Posted by chown33 View Post
Depending on which Xcode version you're using (3.x would be suitable, 4.x I don't know), you can choose Build > Preprocess and inspect the result to see if there's something unexpected after the expanded #import of Foundation.h, directly before your @interface.
Just in case anyone is ever interested, the XCode 4 equivalent is Product > Generate Output > Generate Preprocessed File
jiminaus is offline   0 Reply With Quote
Old Jul 6, 2011, 05:25 PM   #7
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
On what version of Xcode 4 is there a Product > Generate Output > Generate Preprocessed File menu item? I'm using 4.0.2 and I don't see that.
PhoneyDeveloper is offline   0 Reply With Quote
Old Jul 6, 2011, 06:25 PM   #8
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Quote:
Originally Posted by PhoneyDeveloper View Post
On what version of Xcode 4 is there a Product > Generate Output > Generate Preprocessed File menu item? I'm using 4.0.2 and I don't see that.
Ahh, oops. Never mind. I never said anything.
jiminaus is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Previous purchases may be unavailable if they are no longer in the iTunes Store wd89 Mac Applications and Mac App Store 1 Jun 6, 2011 08:13 PM
PS3 Launch May Be Delayed, Cost May Skyrocket - Thread #2 Haoshiro Games 53 Mar 1, 2006 10:46 AM
PS3 Launch May Be Delayed, Cost May Skyrocket clayj Games 112 Feb 27, 2006 10:18 AM
Problems surfing the internet - may be related to ethernet card (or not!) thomasp Macintosh Computers 0 Feb 26, 2005 11:58 AM


All times are GMT -5. The time now is 07:41 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC