最初のファイルで、2番目のファイルへの参照を取得し、そのファイルが持つプロパティを変更できるようにしたいと思います。これが私が持っているものです。参照を返すクラスメソッドを作成しましたが、問題は、メソッドで警告が表示されることです。さらに、ifステートメントを実行すると、実行されていないように見えます。
参照が必要な最初のファイル、参照を取得するためにクラスメソッドを呼び出します
-(void) updateSplitViewDetail{
id detail = (MapViewController*) [MapViewController returnReference];
NSLog(@"%@", [detail class]); //This post MAPVIEWCONTROLLER
//This fails so I cant access the methods inside.
if ([detail isKindOfClass:[MapViewController class]]) {
MapViewController *mapVC = (MapViewController*) detail;
mapVC.delegate = self;
mapVC.annotations = [self mapAnnotations];
}
}
(void)viewDidLoad
{
[super viewDidLoad];
[self updateSplitViewDetail]; //Error may be here?
}
参照したい2番目のファイルは、selfを使用して参照を返します。
- (void)viewDidLoad
{
NSLog(@"%@", [self class]);
[super viewDidLoad];
self.mapView.delegate = self;
// Do any additional setup after loading the view.
}
+(MapViewController*) returnReference{
//I also get an incompatible pointer return warning here?
return self;
}