2011-03-13 39 views
0

我有一個像這樣問題到membervariables分配值,目標C

@interface Preferences1 : UIViewController<selectedtimedelegate> 
{ 

    NSString *Expiration; 
     NSString *incomingalerts; 
     NSString *destroyby; 
} 
我在執行

視圖控制器我試圖導航到另一個屏幕,而分配電流值到下一個視圖 - 控制的成員變量。

-(IBAction)nextbuttonpressed:(id)sender 
{ 

    Preferences2 *addController = [[Preferences2 alloc] initWithNibName:@"Preferences2" bundle:[NSBundle mainBundle]]; 
    addController.Expiration1 = Expiration ; 
    [self.navigationController pushViewController:addController animated:YES]; 
    [addController release]; 


} 

在Preferences2視圖 - 控制當我在Preferences2屏幕我沒有看到價值,其實程序崩潰時被分配的值我已經設置的屬性,像這樣

@property(nonatomic ,retain) NSString *Expiration1; 

。有人可以告訴我我哪裏出錯了。

謝謝。

+0

顯示更多代碼...您是否在@freef2中使用了@synthesize作爲您的屬性...,請使用「過期」而不是「過期」作爲var名稱(常規名稱更易於被其他編碼人員讀取) – meronix 2011-03-13 07:44:39

回答

0

你缺少一些在那裏就像這樣:

你確定這件事情是在Prefernce2,因爲你的代碼顯示了一些錯誤通過輸入錯誤或真正的one.So,一探究竟。

@interface Preferences1(在這裏應該是Preferences2):UIViewController的 {

NSString *Expiration; //You need to define this string in Prefernce2 & synthesize in .m 
    NSString *incomingalerts; 
    NSString *destroyby; 

} @屬性(非原子,保留)的NSString * Expiration1;

+0

preferences1和preferences2是不同的視圖控制器。謝謝任何方式,我的問題是整理出來的。 – Rajashekar 2011-03-13 17:12:37