Reputation: 31
I am building an iphone application that tries to fetch data using web services.The user on clicking the button is navigated to a new view.
The code for login action is
- (IBAction)btnLoginAction:(id)sender
{
[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
activityIndicator=[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(50.0, 50.0, 50, 50)];
[activityIndicator setCenter:CGPointMake(156, 208)];
[activityIndicator startAnimating];
[self.view addSubview:activityIndicator];
soapMessenger=[[SoapMessenger alloc] init];
parser=[[XML_Parsing alloc] init];
[soapMessenger buildSoap:@"CURRENT"];
[soapMessenger setConnection];
where soapMessenger and xml_parsing are classes for creating connections and parsing data ....I am able to parse the xml.But the problem is passing that data to a new view controller....How can I pass the result data to a new class?
Upvotes: 0
Views: 336
Reputation: 4396
If you want to pass data from one class to another you need to create property of the datatype you want to pass in the class in which the data is passed.
Example
FirstVC - Your Class from which you want to pass the value to next View Controller.
SecondVC - Your Second Class to which you want to pass the value.
@interface FirstVC : UIViewController{
NSInteger *testInteger;
}
@implementation FirstVC{
- (IBAction)btnLoginAction:(id)sender
{
SecondVC *second = [[SecondVC alloc] initWithNibName:@"SecondVC" buddle:[NSBundle mainbundle]];
second.receivingInteger=testInteger;
[second release];
}
}
@interface SecondVC{
NSInteger receivingInteger;
}
@property(nonatomic) NSInteger receivingInteger;
Upvotes: 1
Reputation: 10283
You need to define a model class which holds the data parsed from the XML which you then pass to the new view controller via a property.
Upvotes: 0
Reputation: 12423
This is a Model View Controller question. MVC. Your data classes should store the data in your model, and then the relevant part of the model can be passed to the new class - normally by Synthesizing an property of the correct type in the new class, and then alloc/init the new class, and set the property.
Upvotes: 0