gpt4 book ai didi

ios - 无法解析协议(protocol)中的类型

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:45:54 25 4
gpt4 key购买 nike

#import "MPOContactAuthorizationManager.h"

@protocol MPOContactAuthorizationManagerDelegate <NSObject>

- (void)authorizationManger:(MPOContactAuthorizationManager *)manager
didUpdateContactState:(ContactsState)contactState;

@end

MPOContactAuthorizationManagerContactState 未解析为类型,即使它们已在 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;

关于为什么这些没有解决的任何想法?两者都收到错误“Expected a type”

谢谢迈克

最佳答案

你有一个循环依赖。通过删除 #import 行并添加以下内容来更新 MPOContactAuthorizationManagerDelegate.h header :

@class MPOContactAuthorizationManager;

就在 @protocol 行之前。

只需将两者放在一个 .h 文件中(您仍然需要 MPOContactAuthorizationManager 的前向声明):

typedef enum _contactsState {
kContactsStateUnknown,
kContactsStateAllowed,
kContactsStateDisallowed
} ContactsState;

@class MPOContactAuthorizationManager;

@protocol MPOContactAuthorizationManagerDelegate <NSObject>

- (void)authorizationManger:(MPOContactAuthorizationManager *)manager
didUpdateContactState:(ContactsState)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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com