如何将字符串从一个viewcontroller传递给另一个?

问题描述:

我有一个Iphone应用程序,我将字符串从一个视图控制器传递到另一个视图控制器。我的字符串被添加为类中的一个属性。但是当我尝试传递字符串时,它会与释放实例的消息一起崩溃。 ( - [CFString retain]:发送到释放实例的消息)。我的代码看起来像这样如何将字符串从一个viewcontroller传递给另一个?

RewardsViewController *rewards=[[ RewardsViewController alloc] initWithNibName:@" RewardsViewController" bundle:nil];  
rewards.rewardsshopinfoname=stringshopname; 
rewards.rewardsshopinfoaddress1=address1 ; 
rewards.rewardsshopinfoaddress2=address2; 
rewards.rewardsshopinfopoints=total; 
rewards.rewardsarray=self.shoprewardsArray; 
[self.navigationController pushViewController:rewards animated:YES]; 

任何人都可以帮我解决这个问题吗?

+3

您在您的笔尖名称的起始处有一个空格。可能无法加载笔尖。不相关的,但我建议使用骆驼案例约定来命名你的属性/功能(例如,rewardsShopInfoName而不是rewardsshopinfoname)。它更容易阅读。 – Dima 2012-07-11 15:24:40

+0

你怎么申报你的财产? – 2012-07-11 15:30:30

+0

@Dima那么错误信息会不一样? – hacker 2012-07-11 15:33:35

三件事:

  1. 您的笔尖的名字,这可能会造成您的问题的空间。

  2. 您应该强烈考虑使用ARC进行开发。您的所有内存管理问题都已得到解决,并且在许多情况下由ARC进行了改进。

  3. 你给你的属性什么属性?即(非原子,保留)?