Reputation: 13
I got two viewcontrollers. --> AViewController,BViewController
AViewController
need to create an object of BViewController
.
And presentmodalcontroller
: to go to the BViewController
.
And BViewController
need to create an object of the AViewController
as well, so that is can update the label text inside BViewController
's
method.
Has try import in AViewController
in BViewController
. error come out.
unknown type name'ViewController
', did you mean 'UIViewController
'?
If i want access the AViewController too, how do i solve this.
Anyone out there can help me, thank you in advance.
Upvotes: 1
Views: 164
Reputation: 2807
In your BViewController.h
#import AViewcontroller.h
@property(nonatomic,retain) AViewcontroller* aViewcontroller;
In your BViewController.m
@synthesis aViewcontroller;
Then in your AViewcontroller.m where you create your BViewcontroller object lets say bViewcontroller
bViewcontroller.aViewcontroller=self;
//then navigate to bViewcontroller
Then you can update the previous AViewController's label text inside BViewController 's method.
self.aViewcontroller.label_you_want_to_update.text=@"your_text_here";
Hope this helps
Upvotes: 0
Reputation: 5935
In your header of BViewController, before the @interface, put:
@class AViewController;
This will let you declare an instance of AViewController type in BViewController. In the .m file of BViewController, #import AViewcontroller.h
Upvotes: 1