好的,這已被解釋了幾次(我使用this post on SO得到了大部分的方式),但我錯過了一些東西。我能夠順利地編譯,並能設置代表以及來自委託調用方法,但我對構建得到一個警告:在目標C(iPhone)中正確申報委託書
No definition of protocol 'DetailViewControllerDelegate' is found
我有一個DetailViewController,只有RootViewController的。我從DetailViewController調用RootViewController中的方法。我已經委託設置爲這樣:
在RootViewController.h
:
#import "DetailViewController.h"
@interface RootViewController : UITableViewController <NSFetchedResultsControllerDelegate, DetailViewControllerDelegate> //Error shows up here
{
//Some Stuff Here
}
//Some other stuff here
@end
在RootViewController.m
我定義的委託,當我創建使用detailViewController.delegate = self
認爲在DetailViewController.h
:
@protocol DetailViewControllerDelegate;
#import "RootViewController.h"
@interface DetailViewController : UITableViewController <UITextFieldDelegate>
{
id <DetailViewControllerDelegate> delegate;
}
@property (nonatomic, assign) id <DetailViewControllerDelegate> delegate;
@end
@protocol DetailViewControllerDelegate
//some methods that reside in RootViewController.m
@end
我覺得在DetailViewController.h
以上的協議上面聲明的協議很奇怪,但如果我不它不會建立。就像我說的那樣,這些方法被稱爲罰款,並且沒有其他錯誤發生。我在這裏錯過了什麼?
我選擇瞭解決方案(a)。它效果很好。非常感謝。 – 2010-04-29 15:05:01