我已經creted一個UIView子類:如何將值從UIViewController傳遞給UIView?
@interface GraphClass : UIView
{
NSString *str;
}
,我已經指派GraphClass:給名爲UIViewController類的觀點:
@interface GraphViewController : UIViewController
{
}
現在我想傳遞的NSString *量,值從另一個
@interface MonthsListController : UIViewController
{
}
in viewDIdLoad
- (void)viewDidLoad
{
GraphClass *graph = [[GraphClass alloc]init];
graph.str = @"abc";
但UIViewController類我得到NULL值,如果我打印GraphClass
STR值-(void)drawRect:(CGRect)rect
{
NSLog(@"Amount is = %@",str);//NULL VAlue :(
}
}
僅有[搜索] (https://www.google.com/search?q=%40property+and+%40synthesize)for @ @ property' and'@ synthesize' ke ywords。 – 2012-02-13 12:54:02
有很多方法可以做到這一點。嘗試在'AppDelegate'中使用'str',這樣就可以輕鬆保存或打印值。讓我知道它是否有幫助。 – Illep 2012-02-13 12:57:30
是啊阿迪爾我已經設置屬性也:(:(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)或代碼:( – Shreedhar 2012-02-13 12:57:53