2013-08-03 49 views
0
//FirstViewController.m 

#import "EighthViewController.h" 

EighthViewController *able = [[EighthViewController alloc] initWithNibName:@"EighthViewController" bundle:nil]; 
able.extra = @"dd"; //ERROR HERE---------------- 
[self presentViewController:able animated:YES completion:NULL]; 

//EighthViewController.h 
@interface EighthViewController : UIViewController{ 
NSString *extra; 
} 

@property (nonatomic) NSString *extra; 

每當我嘗試使用此代碼(從here)我得到的FirstViewController一個錯誤說另一種觀點認爲:Property 'extra' not found on object of type 'EighthViewController *'傳遞字符串不工作

+0

嘗試[能夠setExtra:@「dd」];它說什麼? – Husyn

+0

另一個錯誤「沒有可見@interface爲'EighthViewController'聲明選擇器'setExtra:'」 – user2649355

+0

@synthesize怎麼樣? – guitarflow

回答

0

你應該補充一點:

@property (nonatomic, retain) NSString *extra; 

到您的文件。並添加以下內容:

@synthesize extra; 

在您的EighthViewController.m文件中。通常它應該工作然後

希望它有幫助

+0

這個答案是正確的,但'@ synthesize'可能沒有必要。 –