我正在构建一个iphone应用程序,该应用程序尝试使用web services.The获取数据,用户单击按钮即可导航到新视图。登录操作的代码为
- (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];其中soapMessenger和xml_parsing是用于创建连接和解析数据的类....I能够解析xml.But问题是将数据传递给新视图controller....How我可以将结果数据传递给新类吗?
发布于 2011-01-05 16:58:41
如果要将数据从一个类传递到另一个类,则需要在传递数据的类中创建要传递的数据类型的属性。
示例
FirstVC -您希望将值从其中传递到下一个视图控制器的类。
SecondVC -您想要将值传递到的第二个类。
@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;发布于 2011-01-05 16:20:17
这是一个模型视图控制器问题。MVC。数据类应该将数据存储在模型中,然后可以将模型的相关部分传递给新类-通常是通过在新类中合成正确类型的属性,然后分配/初始化新类,并设置该属性。
发布于 2011-01-05 16:51:49
您需要定义一个模型类,它保存从XML解析的数据,然后通过一个属性传递给新的视图控制器。
https://stackoverflow.com/questions/4601980
复制相似问题