iewcontroller在另一个视图控制器中为NSString

iewcontroller在另一个视图控制器中为NSString

本文介绍了如何从一个viewcontroller在另一个视图控制器中为NSString设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用Xcode 4.3.2& iOS 5.1模拟器,在我的项目中,我使用两个视图控制器:testingViewController和detailView.我想在testingViewController中选择tableViewCell后为detailView中的NSString设置值.

I'm using Xcode 4.3.2 & iOS 5.1 simulator, and in my project I am using two View Controllers: testingViewController, and detailView. I want to set values for an NSString in detailView once I didSelect tableViewCell in testingViewController.

为此,我使用了以下代码:

For that i used following code:

我在控制台中同时获得wordNamewordMeaning的空值.

I get null values for both wordName and wordMeaning in the console.

任何人都有解决方案吗?在此先感谢!

Anyone have a solution? Thanks in Advance!

推荐答案

如果您在testingViewControllerdetailView之间使用情节提要,请在testingViewControllerprepareForSegue:方法中更改行

If you have a storyboard segue between testingViewController and detailView, in your testingViewController's prepareForSegue: method you should change line

detailView *dVw = [[detailView alloc] init];

detailView *dVw = (detailView *)segue.destinationViewController;

此外,我建议您在detailView.h文件中更改

Also, I recommend you to change in your detailView.h file the

@property (nonatomic, assign) NSString *YOUR_STRING;

@property (nonatomic, copy) NSString *YOUR_STRING;

这篇关于如何从一个viewcontroller在另一个视图控制器中为NSString设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 08:11