I've got two views, view1 calls : [self.view addSubview:view2.view]; then views2 calls: [self.view removeFromSuperview]; and I want to reload data in view1 when view1 reappear but I can't call a method or update a property of view1 because I can't make an#import "view1.h" in view2 (I've made an #import "view2.h" in view1).
This is my code :
View1.h :
-(void)reloadData;
View1.m :
#import « View2.h » ;
View2 *view2 = [[View2 alloc]init];
[self.view addSubview:view2.view];
View2.h :
#import « View1.h »
View2.m :
// I want to call reloadData to reload Data of view1 before removing view2
[self.view removeFromSuperview];
If you reorganize your files properly, you can import view1 in view2 and vice versa. You only need to put the
#import "view1.h"in view2.h if you need any content right there in the .h file. If you only need this in your implementation, you can happily move#import "view1.h"in your view2.m file and thus resolve the circular dependency.Note that in many cases you can skip importing in the .h file if this is only to create instances / paremeters of a type. For example
can be changed to
This basically tells the compiler that there is a thing called
Anotherbut that the details are not important right now. You can then later#import "Another.h"in the accompanying .m file and work as before.