Reputation: 3025
I am adding tracking to an xcode project. In my ViewController.m I get an error for 'Use of undeclared identifier' for a variable that I have declared already.
in ViewController.m
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.analyticsViewEventBundle = [[AnalyticsController sharedAnalyticsController] publishScreenLoadStartedWithScreenName:AnalyticsControllerScreenName_ScreenStyle existingViewEventBundle:self.analyticsViewEventBundle];
}
The above generates use of undeclared identifier 'AnalyticsControllerScreenName_ScreenStyle'
. However, if I change that piece to AnalyticsControllerScreenName_MyStore
there is no error.
If I search XCode I see that both lines appear next to each other in the correct AnalyticsController.m file. Here is an example:
typedef NS_ENUM(NSInteger, AnalyticsControllerScreenName) {
AnalyticsControllerScreenName_MyStore,
AnalyticsControllerScreenName_ScreenStyle,
};
Is there something extra I need to do to be able to use AnalyticsControllerScreenName_ScreenStyle
?
UPDATE:
I removed the comma but still get the error.
typedef NS_ENUM(NSInteger, AnalyticsControllerScreenName) {
AnalyticsControllerScreenName_MyStore,
AnalyticsControllerScreenName_ScreenStyle
};
UPDATE: The problem ended up being that two copies of my AnalyticsController were loaded into the project somehow and the one not visible in the Target navigator was the one being used. I deleted that file, cleaned and built and everything worked as expected after that.
Upvotes: 1
Views: 2195
Reputation: 2874
Your enumeration is being defined as
typedef NS_ENUM(NSInteger, AnalyticsControllerScreenName) {
AnalyticsControllerScreenName_MyStore,
AnalyticsControllerScreenName_ScreenStyle,
};
The problem is that the comma after AnalyticsControllerScreenName_ScreenStyle
tells the compiler that another element is going to be specified, but you didn't provide one. To fix this, do:
typedef NS_ENUM(NSInteger, AnalyticsControllerScreenName) {
AnalyticsControllerScreenName_MyStore,
AnalyticsControllerScreenName_ScreenStyle
};
Upvotes: -1
Reputation: 3029
Remove the comma after AnalyticsControllerScreenName_ScreenStyle.
Try this, it worked for me
typedef enum{
AnalyticsControllerScreenName_MyStore,
AnalyticsControllerScreenName_ScreenStyle
} AnalyticsControllerScreenName;
Upvotes: 2