0

サブクラス FourthViewController を持つビュー コントローラー FirstViewController があります。FirstViewController のインターフェースは次のとおりです。

#import "FourthViewController.h"
@interface FirstViewController : UIViewController <FourthViewControllerDelegate>

FourthViewController の .h には、次のものがあります。

#import "FirstViewController.h"

@protocol FourthViewControllerDelegate
-(void) updateLabel;
@end

@interface FourthViewController : FirstViewController 

@property (weak, nonatomic) id<FourthViewControllerDelegate>delegate;

これにより、次のエラー メッセージが表示されます。「FirstViewController」のインターフェイス宣言が見つかりません。「FourthViewController」のスーパークラスです。このエラーが発生する理由がわかりません。どんなアドバイスも役に立ちます。

4

1 に答える 1

0

デリゲートを.hコントローラーと同じファイルに保持することは、あなたにとって本当に重要ですか? 私はそれを別の.hファイルに入れましたが、すべてうまくいきました。このような:

//FirstViewController.h
#import <Foundation/Foundation.h>

#import "FourthViewControllerDelegate.h"
@interface FirstViewController : UIViewController <FourthViewControllerDelegate>
@end

//FourthViewControllerDelegate.h
#import <Foundation/Foundation.h>

@protocol FourthViewControllerDelegate <NSObject>
-(void) updateLabel;
@end

//FourthViewController.h
#import <Foundation/Foundation.h>

#import "FirstViewController.h"
#import "FourthViewControllerDelegate.h"

@interface FourthViewController : FirstViewController

@property (weak, nonatomic) id<FourthViewControllerDelegate>delegate;
@end
于 2013-08-13T00:56:05.307 に答える