から渡しています。上記のコンパイラエラーがXCodeで発生していますが、何が起こっているのか分かりません。 ApplicationDelegate.mで'obj_setProperty'の引数4を互換性のないポインタ型
#import <UIKit/UIKit.h>
// #import "HeaderPanelViewController.h"
#import "HTTPClientCommunicator.h"
#import "WebSocket.h"
@class HeaderPanelViewController;
@protocol ServerDateTimeUpdating
-(void)serverDateTimeHasBeenUpdatedWithDate:(NSString *) dateString andTime:(NSString *) timeString;
@end
@interface SmartWardPTAppDelegate : NSObject <UIApplicationDelegate, WebSocketDelegate> {
}
@property (nonatomic, retain) id<ServerDateTimeUpdating> *serverDateTimeDelegate;
....
@end
そして、この行の
@synthesize serverDateTimeDelegate;
私は、 "互換性のないポインタ型から 'obj_setProperty' の引数を渡す4" エラーを取得しています。私は少しの研究を行い、「保持する」ことはクラスの型だけで十分であることを発見しました。私が実際にラインから「保持」を削除した場合
@property (nonatomic, retain) id<ServerDateTimeUpdating> *serverDateTimeDelegate;
苦情なしでコンパイルします。しかし、私はそれが間違っていると思います。確かに私の 'id' はクラスタイプでであり、確かにはでなければなりません。ところで、ここで前述のプロトコルを実装して、私のHeaderPanelViewControllerの宣言は次のとおりです。
また@interface HeaderPanelViewController : UIViewController<ServerDateTimeUpdating> {
}
...
@end
、私は実際に私は実際に私を登録するにはセッターを呼び出すとき、私は後でトラックダウン問題を取得保持を削除しない場合デリゲートとしてHeaderPanelViewController:
// Register this instance as the delegate for ServerDateTimeUpdating
// Retrieve the ApplicationDelegate...
ApplicationDelegate *applicationDelegate = (ApplicationDelegate *) [UIApplication sharedApplication].delegate;
// ...and register this instance
applicationDelegate.serverDateTimeDelegate = self;
最後の行は、XCodeのエラーメッセージ「互換性のないポインタ型から 『setServerDateTimeDelegate』の引数1を渡す」の原因となります。
ありがとうございました!それは確かに私の問題を解決しました。 – McKrassy
@McKrassy大歓迎です! :-) –