2016-03-03 40 views
0

我想將我的xml取自一個字符串的數據從uitableviewcontroller1傳遞給另一個viewcontroller2中的另一個nsstring,但是當我在視圖控制器中nslog nsstring時,它顯示NULL。這是我的代碼。由於從uitableviewcontroller傳遞XMLdata到另一個故事板的視圖控制器

UiTableViewController1.h

ViewController2 *aOnly; 

UiTableViewController1.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self sendID]; 
    aOnly = [[ViewController2 alloc] init]; 
    aOnly.audioOnly = [[rssOutputData objectAtIndex:[indexPath row]]xmls_type]; 

} 

ViewController2.h

@interface ViewController : UIViewController 
{ 
    NSString *audioOnly; 
} 
@property (strong, nonatomic) NSString *audioOnly; 

@end 

ViewController2.m

@synthesize audioOnly; 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
     NSLog(@"output is %@", audioOnly); 
} 

回答

0

我認爲有你的第二的viewController的2個實例:

手(分配/初始化)

通過故事板創建了一個創建

一個。

故事板創建的一個不受您的代碼影響。

+0

是的,其實我的ViewController2是在另一個StoryBoard。 –

+0

因此,將數據存儲在外部單例中(例如),然後從viewDidLoad中的單例中獲取它。 – Xvolks

+0

你能解釋我怎麼用我的代碼呢?謝謝 –

相關問題