#import "MPOContactAuthorizationManager.h"
@protocol MPOContactAuthorizationManagerDelegate <NSObject>
- (void)authorizationMangerMPOContactAuthorizationManager *)manager
didUpdateContactStateContactsState)contactState;
@end
MPOContactAuthorizationManager 和 ContactState 不解析为类型,即使它们在 MPOContactAuthorizationManager 中声明:
#import "MPOContactAuthorizationManagerDelegate.h"
typedef enum _contactsState {
kContactsStateUnknown,
kContactsStateAllowed,
kContactsStateDisallowed
} ContactsState;
@interface MPOContactAuthorizationManager : NSObject <UIAlertViewDelegate> {
ContactsState _contactsAuthorizationState;;
}
@property (strong, nonatomic) NSObject<MPOContactAuthorizationManagerDelegate> *delegate;
@property (nonatomic) ContactsState contactsAuthorizationState;
关于为什么这些没有解决的任何想法?两者都收到错误“预期类型”
谢谢
迈克
Best Answer-推荐答案 strong>
你有一个循环依赖。通过删除 #import 行并添加以下内容来更新 MPOContactAuthorizationManagerDelegate.h header :
@class MPOContactAuthorizationManager;
就在 @protocol 行之前。
只需将两者放在一个 .h 文件中(您仍然需要 MPOContactAuthorizationManager 的前向声明):
typedef enum _contactsState {
kContactsStateUnknown,
kContactsStateAllowed,
kContactsStateDisallowed
} ContactsState;
@class MPOContactAuthorizationManager;
@protocol MPOContactAuthorizationManagerDelegate <NSObject>
- (void)authorizationMangerMPOContactAuthorizationManager *)manager
didUpdateContactStateContactsState)contactState;
@end
@interface MPOContactAuthorizationManager : NSObject <UIAlertViewDelegate> {
ContactsState _contactsAuthorizationState;;
}
@property (strong, nonatomic) NSObject<MPOContactAuthorizationManagerDelegate> *delegate;
@property (nonatomic) ContactsState contactsAuthorizationState;
关于ios - 无法解析协议(protocol)中的类型,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/18603379/
|