(初级)试图从ViewController中传递一个数组DetailController [英] (Beginner)Trying to pass an array from ViewController to DetailController
问题描述
我已经加载RootViewController的类数组(recordArray),我需要传递给DetailViewController类,这样我可以在它访问任何变量。我可以成功地通过一个单一的价值,但我不能得到如何将整个阵列跨过去。
I have loaded an array (recordArray) in RootViewController class which I need to pass to the DetailViewController class so that I can access any variable within it. I can pass a single value successfully, but I cannot get how to pass the whole array across.
我创建了一个第二的NSMutableArray recordArray在DetailsViewController.h,添加了@property声明(有保留),并在DetailsViewController.m合成。然后,我添加了以下行DetailsViewController.m
I have created a second NSMutableArray recordArray in DetailsViewController.h, added the @property statement (with retain), and synthesized in DetailsViewController.m. I then added the following line in DetailsViewController.m
recordArray = [[NSMutableArray alloc] initWithArray:self.recordArray];
但只是给了我在详细视图空数组。
but that just gives me an empty array in the detail view.
我已经通过了一些关于这个职位的阅读,但没有发现任何东西,我明白到能够实现。我希望我要对此都错了....
I have read through some of the posts on this, but have not found anything which I understand sufficiently to be able to implement. I expect I'm going about this all wrong....
在此先感谢您的帮助球员。
Thanks in advance for your help guys.
推荐答案
请参阅本code:
<一个href=\"http://stackoverflow.com/questions/5076878/iphone-sdk-how-do-i-pass-an-array-of-values-from-a-viewcontroller-onto-other-vi\">iPhone SDK:如何传递值的数组从的ViewController到其他的ViewController
有可以参考的萨蒂亚的答案。
让我知道如果你需要更多的帮助。
Let me know if you need more help
编辑:
让我们假设有一个的NSArray
名为 secondArray
在 SecondViewController 宣称code>
Let us assume that there is an NSArray
called secondArray
declared in SecondViewController
在定义一个SecondViewController方法,说:
Define a method in SecondViewController which says:
-(void)setValue:(NSArray *)array
{
secondArray = array;
}
希望这有助于。
这篇关于(初级)试图从ViewController中传递一个数组DetailController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!