ios - xcode 未获取头文件中的 typedef

标签 ios cocoa typedef xcode4.6

我在 A.h 文件中有一个 typedef,我在 B.h 中导入了那个 A.h 文件,它使用了相同的 typedef。

在最长的时间里一切正常,但现在它中断了,提示它无法识别 typedef 并在 xcode 中给出“Expect type”错误,即使 xcode 在第二个文件中突出显示了 typedef,这意味着它知道它们在其他地方定义。

如果我手动重新定义该 typedef,那么错误就会消失。但我收到一条警告,提示我正在重新定义 typedef,这是 C11 的一项功能。

我尝试删除派生数据,但错误仍然存​​在。看起来 xcode 在插入导入文件之前试图查找 typedef。有什么线索吗?我正在使用 xcode 4.6

//WebService.h
#import <Foundation/Foundation.h>
#import "AppDelegate.h"

@interface WebService : NSObject


typedef void(^loginUserWithUserNameandPaswordCompletion)(NSDictionary *, NSError*);

+(void)createUserWithName:(NSString*)name
                 andEmail:(NSString*)email
              andPassword:(NSString*)password
             onCompletion:(loginUserWithUserNameandPaswordCompletion) complete;
@end

//DataCenter.h
#import <Foundation/Foundation.h>
#import "WebService.h"
#import "AppDelegate.h"

typedef void(^loginUserWithUserNameandPaswordCompletion)(NSDictionary *, NSError*);
@interface DataCenter : NSObject

+(void) logInUserWithEmail:(NSString*) email
               andPassword:(NSString*)password
              onCompletion:(loginUserWithUserNameandPaswordCompletion)complete;

@end

最佳答案

尝试将 typedef 放在 WebService.h 中的 @interface 之前。

关于ios - xcode 未获取头文件中的 typedef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16128176/

相关文章:

c++ - typedef 一个现有的枚举类型,可能吗?

ios - VoiceOver 滑动时如何水平滚动 UIStackView?

ios - 地理围栏 UILocalNotification 无法快速正常工作

IOS RxSwift 从 Observable 数组创建 Observable 数组

objective-c - 添加列时出现问题 - Cocoa

objective-c - mac cocoa 开发工具集是否被认为是快速应用程序开发?

ios - UITableView setContentOffSet 导致不必要的滚动到顶部

cocoa - Cocoa 中的图形界面按钮

c++ - 是否可以将枚举注入(inject)类范围/命名空间?

c# - `using` 作为 typedef 导致 CS1001