Ios 将XMLdata从uitableviewcontroller传递到另一个情节提要中的viewcontroller
我试图将从uitableviewcontroller1获取的字符串的xml数据传递给另一个viewcontroller2中的另一个nsstring,但当我在viewcontroller中记录nsstring时,它显示为NULL。这是我的密码。谢谢 UiTableViewController1.hIos 将XMLdata从uitableviewcontroller传递到另一个情节提要中的viewcontroller,ios,objective-c,uiviewcontroller,nsxmlparser,uitableview,Ios,Objective C,Uiviewcontroller,Nsxmlparser,Uitableview,我试图将从uitableviewcontroller1获取的字符串的xml数据传递给另一个viewcontroller2中的另一个nsstring,但当我在viewcontroller中记录nsstring时,它显示为NULL。这是我的密码。谢谢 UiTableViewController1.h ViewController2 *aOnly; @interface ViewController : UIViewController { NSString *audioOnly; } @p
ViewController2 *aOnly;
@interface ViewController : UIViewController
{
NSString *audioOnly;
}
@property (strong, nonatomic) NSString *audioOnly;
@end
UiTableViewController1.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self sendID];
aOnly = [[ViewController2 alloc] init];
aOnly.audioOnly = [[rssOutputData objectAtIndex:[indexPath row]]xmls_type];
}
@synthesize audioOnly;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"output is %@", audioOnly);
}
ViewController2.h
ViewController2 *aOnly;
@interface ViewController : UIViewController
{
NSString *audioOnly;
}
@property (strong, nonatomic) NSString *audioOnly;
@end
ViewController2.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self sendID];
aOnly = [[ViewController2 alloc] init];
aOnly.audioOnly = [[rssOutputData objectAtIndex:[indexPath row]]xmls_type];
}
@synthesize audioOnly;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"output is %@", audioOnly);
}
我认为第二个viewController有两个实例: 手工创建的一个(alloc/init) 由故事板创建的一个
脚本创建的脚本不受代码的影响 是的,实际上我的ViewController2在另一个故事板中。因此,请将数据存储在外部单例(例如)中,然后从viewDidLoad中的单例中获取数据。您能否进一步解释我如何使用代码实现这一点。谢谢