を実装していても、プロトコルに宣言されたプロパティを合成しません私は自分自身を合成する。自動プロパティの合成は、その私はそのエラーを得た
これはプロトコルです:私たちはのUIViewControllerはnavigationController性質を持って知っているように実装
@interface BGProfileView : UIViewController
@end
については
@protocol BGIhaveNavigationController <NSObject>
@property (readonly)UINavigationController * navigationController;//This is the problematic property
@end
@protocol BGCommonProtocol <NSObject>
@end
はのUIViewControllerです。だから何が問題なの?私は追加することで警告を削除することができ
@interface BGProfileView() <BGReviewsTableDelegateProtocol>
BGReviewsTableDelegateProtocolプロトコルBGIhaveNavigationControllerプロトコル
を継承します:私はこれを使用する場合
物事は問題の取得
-(UINavigationController *) navigationController
{
return self.navigationController;
}
をしかし、それは不合理です。ある意味で
-(UINavigationController *) navigationController
{
return self.navigationController;
}
-(UINavigationController *) navigationController
はすでにこれは、プロパティ実装が「どこか」と、それは要件がされることを信頼すべきであるということであるコンパイラに指示しますUINavigationController
@Dynamic navigationControllerを試してください。 – Wain
が動作します。しかし、なぜ? navigationControllerは存在しません。 –
既存のクラスのメソッドを置き換えるプロトコルを使用しています。これは決して良い考えではありません。 @dynamicは、実行時に実装が存在することを約束しているので、動作しますが、このプロトコルに準拠するものがすべてView Controllerである場合、なぜプロトコルにnavigationControllerプロパティが必要ですか? – jrturton