【发布时间】:2014-09-22 11:04:10
【问题描述】:
我有一个头文件ApiManager.h,我在其中定义了一个枚举:
typedef enum ApiEndpoint {
// some values
} ApiEndpoint;
在该文件中,我有一个将这些值之一作为参数的方法:
- (NSString *) getPathForEndpoint: (ApiEndpoint) endpoint;
这对 XCode 来说似乎很好。然而,在另一个文件ApiManagerDelegate.h 中,我有以下定义:
- (void) requestToEndpoint: (ApiEndpoint) endpoint succeeded: (id) responseObject;
- (void) requestToEndpoint: (ApiEndpoint) endpoint failed: (NSError *) error;
XCode 将两个 ApiEndpoint 参数标记为错误 expected a type。我已经导入了ApiManager.h,所以ApiEndpoint 确实出现在完成列表中,但由于某种原因,XCode 无法识别它。
我做错了什么?
【问题讨论】:
-
我建议使用 typedef NS_ENUM(NSInteger, UITableViewCellStyle) 宏来定义您的枚举。
标签: objective-c xcode enums