cannot find protocol declaration for "RefreshAudioListViewDelegate"

今天一個很變態的問題卡住了:cannot find protocol declaration for "RefreshAudioListViewDelegate"

1.在PlayerController.h自定義了 一個代理 RefreshAudioListViewDelegate

#import "PlayerListViewController.h"
@protocol RefreshAudioListViewDelegate <NSObject>
- (void) updateCurrentPlayedAudio:(NSUInteger) currentPlayedIndex;
@end

@interface PlayerController : NSObject




2.在PlayerListViewController.h中

#import "PlayerController.h"

@class PlayerController;
@interface PlayerListViewController : UIViewController< RefreshAudioListViewDelegate>
{
    PlayerController                 *playerController;
}


編譯器提示“cannot find protocol declaration for "RefreshAudioListViewDelegate”

分析原因:

在編譯器編譯順序:

1.PlayerListViewController.h文件時,首先發現#import "PlayerController.h",編譯器會跑到PlayerController.h中。
2.在PlayerController.h中首先發現#import "PlayerListViewController.h",編譯器又會到PlayerListViewController中加載內容。
3.這時 當見到
@interface PlayerListViewController : UIViewController< RefreshAudioListViewDelegate>這一句的時候,由於在PlayerController中定義代理的語句還沒有加載,所以編譯器會報錯:
cannot find protocol declaration for "RefreshAudioListViewDelegate"

解決辦法:
刪除PlayerController.h中的
#import "PlayerListViewController.h"



發佈了59 篇原創文章 · 獲贊 5 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章