A basic question I fear. The following code works, and the typedef enumeration is recognised, but I get a warning message “useless storage class specifier in empty declaration”. Am I doing something wrong here and is this the best place to put a typedef enum?
#import <UIKit/UIKit.h>
#import "CoreDataBaseTableViewController.h"
typedef enum ColourType {
BACKGROUND=1,
LOW=2,
HIGH=3,
EXTRA=4
};
@interface ColourList : CoreDataBaseTableViewController <NSFetchedResultsControllerDelegate> {
NSManagedObjectContext* moc;
NSFetchedResultsController* fetchedResultsController;
...
enum ColourType colourTarget;
}
...
You can put an enumeration anywhere in Objective-C which is valid in C. Where you have it now (above the interface) is a common place for enumerations which should be globally available. The warning is because you are using
typedef, but don’t actually define a type. If you simply want to create an enumeration, it isn’t necessary. You just use:You use
typedefto define a type, which makes it easier to reference commonly used structures/unions/enumerations/other types. If you choose to do this, you should place a name for the type after the enumeration definition, and then you can reference the enumeration by using that name without theenumkeyword.Alternatively, you can create the enumeration and type in separate commands with the same effect.