I am new to IOS programming. So far I have been programming in android. So in android when pressing a button code for passing an argument would be like that:
Intent i = new Intent(MainScreen.this,OtherScreen.class);
Bundle b = new Bundle();
b.putString("data_1",data);
i.putExtras(b);
startActivity(i);
and on the activity that opens, i would write something like this:
Bundle b = getIntent().getExtras();
ski_center=b.getString("data_1");
what methods should I need to change in MainScreen and in OtherScreen in IOS to achieve the above.
Basically I will have 3 buttons lets say in my MainScreen and each of it will open the Otherview but each time a different parameter will be passed.
Foe example for each button i have code like these in MainScreen.m
@synthesize fl;
-(IBAction) ifl:(id) sender {
}
So I need your help in where to place the “missing” code, too.
Declare an iVar for your UIViewController ( Android’s Activity) like a property in Java.
In MainViewController.m
Edited: added full code…
Intent i = new Intent(MainScreen.this,OtherScreen.class);
Bundle b = new Bundle();
b.putString(“data_1”,data);
here the MainScreen is the calling code, now in iOS it will be the MainUIViewcontroller
OtherUIViewController.h
in the OtherUIViewController.m
to have the 3 different behaviors, the data can be an int, or an NSString.
And in the
- (void)viewDidLoadyou will check thedatavalue and do 3 diff things.I hope it helps